test-item: Fix string leaks

This fixes:

==16901== 7 bytes in 1 blocks are definitely lost in loss record 9 of 1,154
==16901==    at 0x4A06C50: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==16901==    by 0x36E564F679: g_malloc (gmem.c:97)
==16901==    by 0x36E56688AE: g_strdup (gstrfuncs.c:356)
==16901==    by 0x4C3098F: secret_item_get_label (secret-item.c:1922)
==16901==    by 0x402A65: test_create_sync (test-item.c:203)
==16901==    by 0x36E566FB92: test_case_run (gtestutils.c:2124)
==16901==    by 0x36E566FB92: g_test_run_suite_internal (gtestutils.c:2185)
==16901==    by 0x36E566FD5A: g_test_run_suite_internal (gtestutils.c:2196)
==16901==    by 0x36E56700DA: g_test_run_suite (gtestutils.c:2249)
==16901==    by 0x36E5670110: g_test_run (gtestutils.c:1553)
==16901==    by 0x4C5A0EA: egg_tests_run_with_loop (egg-testing.c:167)
==16901==    by 0x406AAE: main (test-item.c:880)
==16901==-
==16901== 7 bytes in 1 blocks are definitely lost in loss record 10 of 1,154
==16901==    at 0x4A06C50: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==16901==    by 0x36E564F679: g_malloc (gmem.c:97)
==16901==    by 0x36E56688AE: g_strdup (gstrfuncs.c:356)
==16901==    by 0x4C3098F: secret_item_get_label (secret-item.c:1922)
==16901==    by 0x402DB6: test_create_async (test-item.c:249)
==16901==    by 0x36E566FB92: test_case_run (gtestutils.c:2124)
==16901==    by 0x36E566FB92: g_test_run_suite_internal (gtestutils.c:2185)
==16901==    by 0x36E566FD5A: g_test_run_suite_internal (gtestutils.c:2196)
==16901==    by 0x36E56700DA: g_test_run_suite (gtestutils.c:2249)
==16901==    by 0x36E5670110: g_test_run (gtestutils.c:1553)
==16901==    by 0x4C5A0EA: egg_tests_run_with_loop (egg-testing.c:167)
==16901==    by 0x406AAE: main (test-item.c:880)
==16901==-

https://bugzilla.gnome.org/show_bug.cgi?id=756766
This commit is contained in:
Christophe Fergeau 2015-10-17 22:13:02 +02:00
parent 66888a1e6a
commit 4a7de5a403

View File

@ -170,6 +170,8 @@ test_new_async_noexist (Test *test,
g_object_unref (result);
}
#define g_assert_cmpstr_free(str1, op, str2) G_STMT_START { char *str = str1; g_assert_cmpstr (str, op, str2); g_free (str); } G_STMT_END
static void
test_create_sync (Test *test,
gconstpointer unused)
@ -202,7 +204,7 @@ test_create_sync (Test *test,
secret_value_unref (value);
g_assert (g_str_has_prefix (g_dbus_proxy_get_object_path (G_DBUS_PROXY (item)), collection_path));
g_assert_cmpstr (secret_item_get_label (item), ==, "Tunnel");
g_assert_cmpstr_free (secret_item_get_label (item), ==, "Tunnel");
g_assert (secret_item_get_locked (item) == FALSE);
g_object_unref (item);
@ -248,7 +250,7 @@ test_create_async (Test *test,
g_object_add_weak_pointer (G_OBJECT (item), (gpointer *)&item);
g_assert (g_str_has_prefix (g_dbus_proxy_get_object_path (G_DBUS_PROXY (item)), collection_path));
g_assert_cmpstr (secret_item_get_label (item), ==, "Tunnel");
g_assert_cmpstr_free (secret_item_get_label (item), ==, "Tunnel");
g_assert (secret_item_get_locked (item) == FALSE);
g_object_unref (item);