tests/gmenumodel: fix various leaks

Found thanks to ASAN.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau 2022-10-17 14:11:29 +04:00
parent 292c117b98
commit 60b8916fee

View File

@ -1318,6 +1318,7 @@ test_attribute_iter (void)
iter = g_menu_model_iterate_item_attributes (G_MENU_MODEL (menu), 0); iter = g_menu_model_iterate_item_attributes (G_MENU_MODEL (menu), 0);
while (g_menu_attribute_iter_get_next (iter, &name, &v)) while (g_menu_attribute_iter_get_next (iter, &name, &v))
g_hash_table_insert (found, g_strdup (name), v); g_hash_table_insert (found, g_strdup (name), v);
g_object_unref (iter);
g_assert_cmpint (g_hash_table_size (found), ==, 6); g_assert_cmpint (g_hash_table_size (found), ==, 6);
@ -1363,19 +1364,23 @@ test_links (void)
item = g_menu_item_new ("test2", NULL); item = g_menu_item_new ("test2", NULL);
g_menu_item_set_link (item, "submenu", m); g_menu_item_set_link (item, "submenu", m);
g_menu_prepend_item (menu, item); g_menu_prepend_item (menu, item);
g_object_unref (item);
item = g_menu_item_new ("test1", NULL); item = g_menu_item_new ("test1", NULL);
g_menu_item_set_link (item, "section", m); g_menu_item_set_link (item, "section", m);
g_menu_insert_item (menu, 0, item); g_menu_insert_item (menu, 0, item);
g_object_unref (item);
item = g_menu_item_new ("test3", NULL); item = g_menu_item_new ("test3", NULL);
g_menu_item_set_link (item, "wallet", m); g_menu_item_set_link (item, "wallet", m);
g_menu_insert_item (menu, 1000, item); g_menu_insert_item (menu, 1000, item);
g_object_unref (item);
item = g_menu_item_new ("test4", NULL); item = g_menu_item_new ("test4", NULL);
g_menu_item_set_link (item, "purse", m); g_menu_item_set_link (item, "purse", m);
g_menu_item_set_link (item, "purse", NULL); g_menu_item_set_link (item, "purse", NULL);
g_menu_append_item (menu, item); g_menu_append_item (menu, item);
g_object_unref (item);
g_assert_cmpint (g_menu_model_get_n_items (G_MENU_MODEL (menu)), ==, 4); 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 (m1);
g_object_unref (m2); g_object_unref (m2);
g_object_unref (sub);
} }
static void static void