From: Matthias Clasen Date: Tue, 4 Feb 2020 23:25:15 +0000 (+0100) Subject: icontheme: Fix various memory leaks X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~20^2~94 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=25c25ba5c1e3ec9d8ce00728e09b44b2d11e6f52;p=gtk4.git icontheme: Fix various memory leaks Tasks need to be unreffed too. --- diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c index 5293bbb9b3..d497d2e248 100644 --- a/gtk/gtkicontheme.c +++ b/gtk/gtkicontheme.c @@ -728,6 +728,7 @@ gtk_icon_theme_load_in_thread (GtkIconTheme *self) task = g_task_new (self, NULL, NULL, NULL); g_task_set_task_data (task, g_object_ref (self), g_object_unref); g_task_run_in_thread (task, load_theme_thread); + g_object_unref (task); } /** @@ -2853,24 +2854,29 @@ scan_resource_directory (GtkIconTheme *self, children = g_resources_enumerate_children (full_dir, 0, NULL); - for (i = 0; children != NULL && children[i]; i++) + if (children) { - const char *name = children[i]; - gchar *base_name; - IconCacheFlag suffix, hash_suffix; + for (i = 0; children[i]; i++) + { + const char *name = children[i]; + gchar *base_name; + IconCacheFlag suffix, hash_suffix; - suffix = suffix_from_name (name); - if (suffix == ICON_CACHE_FLAG_NONE) - continue; + suffix = suffix_from_name (name); + if (suffix == ICON_CACHE_FLAG_NONE) + continue; - if (!icons) - icons = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + if (!icons) + icons = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - base_name = strip_suffix (name); + base_name = strip_suffix (name); - hash_suffix = GPOINTER_TO_INT (g_hash_table_lookup (icons, base_name)); - /* takes ownership of base_name */ - g_hash_table_replace (icons, base_name, GUINT_TO_POINTER (hash_suffix|suffix)); + hash_suffix = GPOINTER_TO_INT (g_hash_table_lookup (icons, base_name)); + /* takes ownership of base_name */ + g_hash_table_replace (icons, base_name, GUINT_TO_POINTER (hash_suffix|suffix)); + } + + g_strfreev (children); } return icons;