From 430e55a535752dfa4a9b58393c1a7086362fa65e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 29 May 2024 20:43:43 +0200 Subject: [PATCH] backends/color-store: Clarify the color profile ownership fixing the key leak We were leaking the color profile path keys but also it wasn't clear how the ownership was passed to the new hash-table, so let's just remove it from the pending hash table and add it to the new one including the expected reference. This is safe because we were still adding a temporary extra ref to the profile Part-of: --- src/backends/meta-color-store.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/backends/meta-color-store.c b/src/backends/meta-color-store.c index 35c2ef28c..d24598844 100644 --- a/src/backends/meta-color-store.c +++ b/src/backends/meta-color-store.c @@ -99,13 +99,16 @@ on_directory_profile_ready (MetaColorProfile *color_profile, g_object_ref (color_profile); - if (!g_hash_table_steal (color_store->pending_local_profiles, - meta_color_profile_get_file_path (color_profile))) - g_warn_if_reached (); + if (!g_hash_table_remove (color_store->pending_local_profiles, + meta_color_profile_get_file_path (color_profile))) + { + g_object_unref (color_profile); + g_warn_if_reached (); + } g_hash_table_insert (color_store->profiles, g_strdup (meta_color_profile_get_id (color_profile)), - color_profile); + g_object_ref (color_profile)); meta_topic (META_DEBUG_COLOR, "Created colord profile '%s' from '%s'", meta_color_profile_get_id (color_profile),