From e2641092b8515ca2286d233ec1b5caa4ee1a37f0 Mon Sep 17 00:00:00 2001 From: "Adam M. Trofa" <5453854+amptrofa@users.noreply.github.com> Date: Fri, 19 Mar 2021 18:20:56 -0400 Subject: [PATCH] Fix imlib image leak Double-adding the image caused imlib's reference count to increment twice, requiring us to free it twice to actually release the cached image, but we only ever free it once. Fixes #704, likely #721 (leak is not present with -DENABLE_RSVG=OFF), possibly #650 based on connection to execp, maybe others since this was introduced nearly 6 years ago in 1d02b858 in launcher-specific code. --- src/util/common.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/util/common.c b/src/util/common.c index 7d868c1..d556c2e 100644 --- a/src/util/common.c +++ b/src/util/common.c @@ -794,8 +794,8 @@ Imlib_Image load_image(const char *path, int cached) static unsigned long counter = 0; if (debug_icons) fprintf(stderr, "tint2: loading icon %s\n", path); -#ifdef HAVE_RSVG image = imlib_load_image(path); +#ifdef HAVE_RSVG if (!image && g_str_has_suffix(path, ".svg")) { char tmp_filename[128]; snprintf(tmp_filename, sizeof(tmp_filename), "/tmp/tint2-%d-%lu.png", (int)getpid(), counter); @@ -825,11 +825,8 @@ Imlib_Image load_image(const char *path, int cached) unlink(tmp_filename); } } - } else -#endif - { - image = imlib_load_image(path); } +#endif imlib_context_set_image(image); imlib_image_set_changes_on_disk(); return image;