diff options
author | Daniel Friesel <derf@finalrewind.org> | 2020-12-05 22:13:58 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2020-12-05 22:13:58 +0100 |
commit | cb66a31027a1202ff075cac266354b5acd3cc10d (patch) | |
tree | 2e8f242c4fb5d05b3232fef8f351954da6268244 /src | |
parent | f846eb550d128a5cd1b24e2ec4d4030a87c289de (diff) |
fix memory leak when using exif=1 and reloading an image
Diffstat (limited to 'src')
-rw-r--r-- | src/imlib.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/imlib.c b/src/imlib.c index f42e906..f21290f 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -373,7 +373,7 @@ int feh_load_image(Imlib_Image * im, feh_file * file) if (file->ed) { exif_data_unref(file->ed); } - file->ed = exif_get_data(tmpname); + file->ed = exif_data_new_from_file(tmpname); #endif } if (!opt.use_conversion_cache && ((image_source != SRC_HTTP) || !opt.keep_http)) @@ -385,6 +385,17 @@ int feh_load_image(Imlib_Image * im, feh_file * file) if (image_source != SRC_HTTP && !opt.use_conversion_cache) free(tmpname); + } else if (im) { +#ifdef HAVE_LIBEXIF + /* + * if we're called from within feh_reload_image, file->ed is already + * populated. + */ + if (file->ed) { + exif_data_unref(file->ed); + } + file->ed = exif_data_new_from_file(file->filename); +#endif } if ((err) || (!im)) { @@ -409,14 +420,12 @@ int feh_load_image(Imlib_Image * im, feh_file * file) #ifdef HAVE_LIBEXIF int orientation = 0; - ExifData *exifData = exif_data_new_from_file(file->filename); - if (exifData) { - ExifByteOrder byteOrder = exif_data_get_byte_order(exifData); - ExifEntry *exifEntry = exif_data_get_entry(exifData, EXIF_TAG_ORIENTATION); + if (file->ed) { + ExifByteOrder byteOrder = exif_data_get_byte_order(file->ed); + ExifEntry *exifEntry = exif_data_get_entry(file->ed, EXIF_TAG_ORIENTATION); if (exifEntry && opt.auto_rotate) orientation = exif_get_short(exifEntry->data, byteOrder); } - file->ed = exifData; if (orientation == 2) gib_imlib_image_flip_horizontal(*im); |