@@ -151,7 +151,8 @@ void ImageFind::ConnCompAndRectangularize(Pix* pix, Boxa** boxa, Pixa** pixa) {
151
151
// Rectangularize the individual images. If a sharp edge in vertical and/or
152
152
// horizontal occupancy can be found, it indicates a probably rectangular
153
153
// image with unwanted bits merged on, so clip to the approximate rectangle.
154
- int npixes = pixaGetCount (*pixa);
154
+ int npixes = 0 ;
155
+ if (*boxa != nullptr && *pixa != nullptr ) npixes = pixaGetCount (*pixa);
155
156
for (int i = 0 ; i < npixes; ++i) {
156
157
int x_start, x_end, y_start, y_end;
157
158
Pix* img_pix = pixaGetPix (*pixa, i, L_CLONE);
@@ -1293,7 +1294,8 @@ void ImageFind::FindImagePartitions(Pix* image_pix,
1293
1294
Pixa* pixa;
1294
1295
ConnCompAndRectangularize (image_pix, &boxa, &pixa);
1295
1296
// Iterate the connected components in the image regions mask.
1296
- int nboxes = boxaGetCount (boxa);
1297
+ int nboxes = 0 ;
1298
+ if (boxa != nullptr && pixa != nullptr ) nboxes = boxaGetCount (boxa);
1297
1299
for (int i = 0 ; i < nboxes; ++i) {
1298
1300
l_int32 x, y, width, height;
1299
1301
boxaGetBoxGeometry (boxa, i, &x, &y, &width, &height);
0 commit comments