Skip to content

Commit 8dab9c3

Browse files
authored
Check image size when reading targa file (#3058)
Throw an error when image width or height is 0. Fixes mozilla/mozjpeg#140, closes #7.
1 parent e8b6c05 commit 8dab9c3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

dlib/external/libjpeg/rdtarga.c

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

371372
if (subtype > 8) {

0 commit comments

Comments
 (0)