Skip to content

Commit 82923eb

Browse files
fbossendcommander
authored andcommitted
Check image size when reading targa file
Throw an error when image width or height is 0. Fixes mozilla/mozjpeg#140, closes flutter#7.
1 parent a3ef34c commit 82923eb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

rdtarga.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@ start_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
364364
if (cmaptype > 1 || /* cmaptype must be 0 or 1 */
365365
source->pixel_size < 1 || source->pixel_size > 4 ||
366366
(UCH(targaheader[16]) & 7) != 0 || /* bits/pixel must be multiple of 8 */
367-
interlace_type != 0) /* currently don't allow interlaced image */
367+
interlace_type != 0 || /* currently don't allow interlaced image */
368+
width == 0 || height == 0) /* image width/height must be non-zero */
368369
ERREXIT(cinfo, JERR_TGA_BADPARMS);
369370

370371
if (subtype > 8) {

0 commit comments

Comments
 (0)