Fix signed integer overflow.

The overflow happens for INT_MAX so the code just needs to be moved down.
pull/23283/head
Vincent Rabaud 2 years ago
parent 23dec329b4
commit f7ce715596
  1. 5
      modules/imgproc/src/stb_truetype.cpp

@ -3530,11 +3530,14 @@ STBTT_DEF unsigned char* stbtt_GetGlyphBitmapSubpixelRealloc(const stbtt_fontinf
iy1 = STBTT_max(iy1, y);
}
}
int w = ix1 - ix0 + 1, h = iy1 - iy0 + 1;
int w, h;
if (ix0 == INT_MAX || iy0 == INT_MAX || ix1 == INT_MIN || iy1 == INT_MIN ) {
w = h = 0;
ix0 = pad_x;
iy0 = pad_y;
} else {
w = ix1 - ix0 + 1;
h = iy1 - iy0 + 1;
}
if (width) *width = w;
if (height) *height = h;

Loading…
Cancel
Save