Skip to content

Commit

Permalink
Check image size when reading targa file (#3058)
Browse files Browse the repository at this point in the history
Throw an error when image width or height is 0.

Fixes mozilla/mozjpeg#140, closes #7.
  • Loading branch information
tabudz authored Feb 27, 2025
1 parent e8b6c05 commit 8dab9c3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dlib/external/libjpeg/rdtarga.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ start_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
width <= 0 || height <= 0 ||
source->pixel_size < 1 || source->pixel_size > 4 ||
(UCH(targaheader[16]) & 7) != 0 || /* bits/pixel must be multiple of 8 */
interlace_type != 0) /* currently don't allow interlaced image */
interlace_type != 0 || /* currently don't allow interlaced image */
width == 0 || height == 0) /* image width/height must be non-zero */
ERREXIT(cinfo, JERR_TGA_BADPARMS);

if (subtype > 8) {
Expand Down

0 comments on commit 8dab9c3

Please sign in to comment.