From aed909853074d3926115c9fc54a3c5b9a3b30fa8 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 14 Nov 2023 11:00:01 +0000 Subject: [PATCH 1/3] girepository: Fix various leaks in cmph-bdz-test See https://gitlab.gnome.org/GNOME/glib/-/jobs/3294034 Signed-off-by: Philip Withnall --- girepository/cmph-bdz-test.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/girepository/cmph-bdz-test.c b/girepository/cmph-bdz-test.c index cf74f1a520..8a9accecb0 100644 --- a/girepository/cmph-bdz-test.c +++ b/girepository/cmph-bdz-test.c @@ -42,6 +42,10 @@ build (void) size = cmph_size (c); g_assert (size == g_strv_length (strings)); + cmph_config_destroy (config); + cmph_io_vector_adapter_destroy (io); + g_strfreev (strings); + return c; } @@ -87,6 +91,8 @@ test_search (void) hashes[i++] = hash; assert_hashes_unique (G_N_ELEMENTS (hashes), &hashes[0]); + + cmph_destroy (c); } static void @@ -123,6 +129,8 @@ test_search_packed (void) hashes[i++] = hash; assert_hashes_unique (G_N_ELEMENTS (hashes), &hashes[0]); + + g_free (buf); } int -- GitLab From 1a979ab4947fc259af01ea65263aaa4d417553fb Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 14 Nov 2023 11:00:21 +0000 Subject: [PATCH 2/3] gutils: Fix an unlikely minor leak in g_build_user_data_dir() A leak can happen if the `data_dir` is the empty string. See https://gitlab.gnome.org/GNOME/glib/-/jobs/3294034 Signed-off-by: Philip Withnall --- glib/gutils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/glib/gutils.c b/glib/gutils.c index dfe115843e..ffc7d750c7 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -1883,6 +1883,7 @@ g_build_user_data_dir (void) if (!data_dir || !data_dir[0]) { gchar *home_dir = g_build_home_dir (); + g_free (data_dir); data_dir = g_build_filename (home_dir, ".local", "share", NULL); g_free (home_dir); } -- GitLab From 89b0c1b304038409e192a28991a468036649f518 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 14 Nov 2023 11:01:04 +0000 Subject: [PATCH 3/3] glib.supp: Allow definite leaks of util dir paths These are one-time leaks, and happen if the util dir paths are built via these code paths, and then subsequently overwritten using `g_set_user_dirs()` (typically as part of a unit test). The additions to `glib.supp` correspond to the `g_ignore_leak()` calls in `gutils.c`. Unfortunately `g_ignore_leak()` only affects asan, not valgrind. See https://gitlab.gnome.org/GNOME/glib/-/jobs/3294034 Signed-off-by: Philip Withnall --- tools/glib.supp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/glib.supp b/tools/glib.supp index aaf97dac08..cb379e2f5a 100644 --- a/tools/glib.supp +++ b/tools/glib.supp @@ -867,7 +867,7 @@ { g_get_system_data_dirs Memcheck:Leak - match-leak-kinds:reachable + match-leak-kinds:definite,reachable fun:malloc ... fun:g_build_system_data_dirs @@ -878,7 +878,7 @@ { g_get_user_data_dir Memcheck:Leak - match-leak-kinds:reachable + match-leak-kinds:definite,reachable fun:realloc ... fun:g_build_user_data_dir @@ -889,7 +889,7 @@ { g_get_home_dir Memcheck:Leak - match-leak-kinds:reachable + match-leak-kinds:definite,reachable fun:malloc ... fun:g_build_home_dir -- GitLab