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,
179
179
uint32_t skip = (exifdata[0 ]<<24 ) | (exifdata[1 ]<<16 ) | (exifdata[2 ]<<8 ) | exifdata[3 ];
180
180
if (skip > (exifsize - 4 )) {
181
181
fprintf (stderr, " Invalid EXIF data (offset too large)\n " );
182
+ free (exifdata);
183
+ jpeg_destroy_compress (&cinfo);
184
+ fclose (fp);
182
185
return false ;
183
186
}
184
187
skip += 4 ;
@@ -188,6 +191,9 @@ bool JpegEncoder::Encode(const struct heif_image_handle* handle,
188
191
189
192
if (size > std::numeric_limits<uint32_t >::max ()) {
190
193
fprintf (stderr, " EXIF larger than 4GB is not supported" );
194
+ free (exifdata);
195
+ jpeg_destroy_compress (&cinfo);
196
+ fclose (fp);
191
197
return false ;
192
198
}
193
199
@@ -258,6 +264,8 @@ bool JpegEncoder::Encode(const struct heif_image_handle* handle,
258
264
259
265
if (heif_image_get_bits_per_pixel (image, heif_channel_Y) != 8 ) {
260
266
fprintf (stderr, " JPEG writer cannot handle image with >8 bpp.\n " );
267
+ jpeg_destroy_compress (&cinfo);
268
+ fclose (fp);
261
269
return false ;
262
270
}
263
271
You can’t perform that action at this time.
0 commit comments