File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,9 @@ bool JpegEncoder::Encode(const struct heif_image_handle* handle,
179179 uint32_t skip = (exifdata[0 ]<<24 ) | (exifdata[1 ]<<16 ) | (exifdata[2 ]<<8 ) | exifdata[3 ];
180180 if (skip > (exifsize - 4 )) {
181181 fprintf (stderr, " Invalid EXIF data (offset too large)\n " );
182+ free (exifdata);
183+ jpeg_destroy_compress (&cinfo);
184+ fclose (fp);
182185 return false ;
183186 }
184187 skip += 4 ;
@@ -188,6 +191,9 @@ bool JpegEncoder::Encode(const struct heif_image_handle* handle,
188191
189192 if (size > std::numeric_limits<uint32_t >::max ()) {
190193 fprintf (stderr, " EXIF larger than 4GB is not supported" );
194+ free (exifdata);
195+ jpeg_destroy_compress (&cinfo);
196+ fclose (fp);
191197 return false ;
192198 }
193199
@@ -258,6 +264,8 @@ bool JpegEncoder::Encode(const struct heif_image_handle* handle,
258264
259265 if (heif_image_get_bits_per_pixel (image, heif_channel_Y) != 8 ) {
260266 fprintf (stderr, " JPEG writer cannot handle image with >8 bpp.\n " );
267+ jpeg_destroy_compress (&cinfo);
268+ fclose (fp);
261269 return false ;
262270 }
263271
You can’t perform that action at this time.
0 commit comments