Fix leak when changing window logo

This commit is contained in:
Kovid Goyal
2021-12-04 13:59:16 +05:30
parent 799881af2d
commit 0456399ce5
2 changed files with 5 additions and 1 deletions

View File

@@ -230,6 +230,7 @@ set_window_logo(Window *w, const char *path, const ImageAnchorPosition pos, floa
if (path && path[0]) {
window_logo_id_t wl = find_or_create_window_logo(global_state.all_window_logos, path);
if (wl) {
if (w->window_logo.id) decref_window_logo(global_state.all_window_logos, w->window_logo.id);
w->window_logo.id = wl;
w->window_logo.position = pos;
w->window_logo.alpha = alpha;

View File

@@ -53,7 +53,10 @@ find_or_create_window_logo(WindowLogoTable *head, const char *path) {
WindowLogoItem *s = NULL;
unsigned _uthash_hfstr_keylen = (unsigned)uthash_strlen(path);
HASH_FIND(hh_path, head->by_path, path, _uthash_hfstr_keylen, s);
if (s) return s->id;
if (s) {
s->refcnt++;
return s->id;
}
s = calloc(1, sizeof *s);
size_t size;
if (!s) { PyErr_NoMemory(); return 0; }