Merge cherrypicks of [13083486, 13083716, 13083431, 13083573, 13083545, 13083736, 13083575, 13083776, 13083778, 13083757, 13083547, 13083530, 13083719, 13083780, 13083739, 13083549, 13083741, 13083742, 13083590, 13083593, 13083594, 13083816, 13083818, 13083820, 13083822, 13083824, 13083827, 13083828, 13083552, 13083760, 13083762, 13083764, 13083782, 13083784, 13083831, 13083787, 13083766, 13083835, 13083745, 13083877, 13083720, 13083489, 13083491, 13083274, 13083859, 13083897] into rvc-qpr1-release
Change-Id: I8949adbc3640372d52fef078a660129b0159044f
diff --git a/src/sfnt/pngshim.c b/src/sfnt/pngshim.c
index ca85d97..15f4e16 100644
--- a/src/sfnt/pngshim.c
+++ b/src/sfnt/pngshim.c
@@ -327,6 +327,13 @@
if ( populate_map_and_metrics )
{
+ /* reject too large bitmaps similarly to the rasterizer */
+ if ( imgHeight > 0x7FFF || imgWidth > 0x7FFF )
+ {
+ error = FT_THROW( Array_Too_Large );
+ goto DestroyExit;
+ }
+
metrics->width = (FT_UShort)imgWidth;
metrics->height = (FT_UShort)imgHeight;
@@ -335,13 +342,6 @@
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 */