Fix imlib leak (issue #704)

This commit is contained in:
Chris Lee 2018-04-17 19:37:10 +00:00
parent 21466cc94e
commit 131704081c

View file

@ -789,11 +789,7 @@ Imlib_Image load_image(const char *path, int cached)
{ {
Imlib_Image image; Imlib_Image image;
#ifdef HAVE_RSVG #ifdef HAVE_RSVG
if (cached) { image = imlib_load_image(path);
image = imlib_load_image_immediately(path);
} else {
image = imlib_load_image_immediately_without_cache(path);
}
if (!image && g_str_has_suffix(path, ".svg")) { if (!image && g_str_has_suffix(path, ".svg")) {
char tmp_filename[128]; char tmp_filename[128];
snprintf(tmp_filename, sizeof(tmp_filename), "/tmp/tint2-%d.png", (int)getpid()); snprintf(tmp_filename, sizeof(tmp_filename), "/tmp/tint2-%d.png", (int)getpid());
@ -818,19 +814,17 @@ Imlib_Image load_image(const char *path, int cached)
// Parent // Parent
close(fd); close(fd);
waitpid(pid, 0, 0); waitpid(pid, 0, 0);
image = imlib_load_image_immediately_without_cache(tmp_filename); image = imlib_load_image_immediately(tmp_filename);
unlink(tmp_filename); unlink(tmp_filename);
} }
} }
} else } else
#endif #endif
{ {
if (cached) { image = imlib_load_image(path);
image = imlib_load_image_immediately(path);
} else {
image = imlib_load_image_immediately_without_cache(path);
}
} }
imlib_context_set_image(image);
imlib_image_set_changes_on_disk();
return image; return image;
} }