From bf506e11b79c470ebb7840f1b4f9545a9cfb690c Mon Sep 17 00:00:00 2001 From: Frank Bossen Date: Mon, 29 Dec 2014 18:38:36 +0100 Subject: [PATCH] Check image size when reading targa file Throw an error when image width or height is 0 when reading a targa file Solves #140 --- rdtarga.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rdtarga.c b/rdtarga.c index afd17c43..4e38258d 100644 --- a/rdtarga.c +++ b/rdtarga.c @@ -364,7 +364,8 @@ start_input_tga (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) if (cmaptype > 1 || /* cmaptype must be 0 or 1 */ 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 nonzero */ ERREXIT(cinfo, JERR_TGA_BADPARMS); if (subtype > 8) {