blob: e7cc6b0aa389d8457026a57556e540cd210170dd [file] [log] [blame]
diff --git a/src/sfnt/pngshim.c b/src/sfnt/pngshim.c
index 2e64e58..95b161f 100644
--- a/src/sfnt/pngshim.c
+++ b/src/sfnt/pngshim.c
@@ -332,6 +332,13 @@
if ( populate_map_and_metrics )
{
+ /* reject too large bitmaps similarly to the rasterizer */
+ if ( imgWidth > 0x7FFF || imgHeight > 0x7FFF )
+ {
+ error = FT_THROW( Array_Too_Large );
+ goto DestroyExit;
+ }
+
metrics->width = (FT_UShort)imgWidth;
metrics->height = (FT_UShort)imgHeight;
@@ -340,14 +347,7 @@
map->pixel_mode = FT_PIXEL_MODE_BGRA;
map->pitch = (int)( map->width * 4 );
map->num_grays = 256;
-
- /* reject too large bitmaps similarly to the rasterizer */
- if ( map->rows > 0x7FFF || map->width > 0x7FFF )
- {
- error = FT_THROW( Array_Too_Large );
- goto DestroyExit;
- }
- }
+ }
/* convert palette/gray image to rgb */
if ( color_type == PNG_COLOR_TYPE_PALETTE )