From 60b8916fee56b6e245825d4246f6910bc8a0231a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 17 Oct 2022 14:11:29 +0400 Subject: [PATCH 1/2] tests/gmenumodel: fix various leaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Found thanks to ASAN. Signed-off-by: Marc-André Lureau --- gio/tests/gmenumodel.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gio/tests/gmenumodel.c b/gio/tests/gmenumodel.c index 492daf8c4..618a29eae 100644 --- a/gio/tests/gmenumodel.c +++ b/gio/tests/gmenumodel.c @@ -1318,6 +1318,7 @@ test_attribute_iter (void) iter = g_menu_model_iterate_item_attributes (G_MENU_MODEL (menu), 0); while (g_menu_attribute_iter_get_next (iter, &name, &v)) g_hash_table_insert (found, g_strdup (name), v); + g_object_unref (iter); g_assert_cmpint (g_hash_table_size (found), ==, 6); @@ -1363,19 +1364,23 @@ test_links (void) item = g_menu_item_new ("test2", NULL); g_menu_item_set_link (item, "submenu", m); g_menu_prepend_item (menu, item); + g_object_unref (item); item = g_menu_item_new ("test1", NULL); g_menu_item_set_link (item, "section", m); g_menu_insert_item (menu, 0, item); + g_object_unref (item); item = g_menu_item_new ("test3", NULL); g_menu_item_set_link (item, "wallet", m); g_menu_insert_item (menu, 1000, item); + g_object_unref (item); item = g_menu_item_new ("test4", NULL); g_menu_item_set_link (item, "purse", m); g_menu_item_set_link (item, "purse", NULL); g_menu_append_item (menu, item); + g_object_unref (item); g_assert_cmpint (g_menu_model_get_n_items (G_MENU_MODEL (menu)), ==, 4); @@ -1456,6 +1461,7 @@ test_convenience (void) g_object_unref (m1); g_object_unref (m2); + g_object_unref (sub); } static void From ad0fd6c5d9da1b1c00fdbc0cb3d1a9829e99faeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 17 Oct 2022 14:32:09 +0400 Subject: [PATCH 2/2] gio/module: fix leak when there is no cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GIOModule is a helper object, we keep it around when there is a cache, but we should free it otherwise. Found thanks to ASAN. Signed-off-by: Marc-André Lureau --- gio/giomodule.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/gio/giomodule.c b/gio/giomodule.c index fce60e9fc..aa1623156 100644 --- a/gio/giomodule.c +++ b/gio/giomodule.c @@ -581,12 +581,8 @@ g_io_modules_scan_all_in_directory_with_scope (const char *dirname, if (g_type_module_use (G_TYPE_MODULE (module))) g_type_module_unuse (G_TYPE_MODULE (module)); /* Unload */ else - { /* Failure to load */ - g_printerr ("Failed to load module: %s\n", path); - g_object_unref (module); - g_free (path); - continue; - } + g_printerr ("Failed to load module: %s\n", path); + g_object_unref (module); } g_free (path);