From eaceb6aa881b97de6a7661096b9fa07ea30c269d Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 8 Apr 2020 16:12:16 +0200 Subject: fix a memory leak when loading a non-native image more than once feh_file_info_load is called even if file_info is already populated, so the original file_info struct is never freed. This results in a leak of ~44 Byte for each subsequenc image load --- src/imlib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/imlib.c b/src/imlib.c index 8baa886..1cc253c 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -254,7 +254,19 @@ int feh_load_image(Imlib_Image * im, feh_file * file) if (!err && im) { real_filename = file->filename; file->filename = tmpname; + + /* + * feh does not associate a non-native image with its temporary + * filename and may delete the temporary file right after loading. + * To ensure that it is still aware of image size, dimensions, etc., + * file_info is preloaded here. To avoid a memory leak when loading + * a non-native file multiple times in a slideshow, the file_info + * struct is freed first. If file->info is not set, feh_file_info_free + * is a no-op. + */ + feh_file_info_free(file->info); feh_file_info_load(file, *im); + file->filename = real_filename; #ifdef HAVE_LIBEXIF file->ed = exif_get_data(tmpname); -- cgit v1.2.3