test-item: Fix GError leak

This fixes:
==16901== 94 (16 direct, 78 indirect) bytes in 1 blocks are definitely lost in loss record 901 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 0x36E5666CD2: g_slice_alloc (gslice.c:1007)
==16901==    by 0x36E563522B: g_error_new_valist (gerror.c:386)
==16901==    by 0x36E563560A: g_set_error (gerror.c:560)
==16901==    by 0x4C2CFB2: secret_item_initable_init (secret-item.c:480)
==16901==    by 0x36E6E5D83E: g_initable_new_valist (ginitable.c:228)
==16901==    by 0x36E6E5D8F5: g_initable_new (ginitable.c:146)
==16901==    by 0x4C3E711: secret_item_new_for_dbus_path_sync (secret-paths.c:286)
==16901==    by 0x402506: test_new_sync_noexist (test-item.c:121)
==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)

https://bugzilla.gnome.org/show_bug.cgi?id=756766
This commit is contained in:
Christophe Fergeau 2015-10-17 22:05:49 +02:00
parent a2e76aede7
commit cd96ccffcd

View File

@ -121,6 +121,7 @@ test_new_sync_noexist (Test *test,
item = secret_item_new_for_dbus_path_sync (test->service, item_path, SECRET_ITEM_NONE, NULL, &error); item = secret_item_new_for_dbus_path_sync (test->service, item_path, SECRET_ITEM_NONE, NULL, &error);
g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD); g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD);
g_assert (item == NULL); g_assert (item == NULL);
g_clear_error (&error);
} }
static void static void
@ -165,6 +166,7 @@ test_new_async_noexist (Test *test,
item = secret_item_new_for_dbus_path_finish (result, &error); item = secret_item_new_for_dbus_path_finish (result, &error);
g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD); g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD);
g_assert (item == NULL); g_assert (item == NULL);
g_clear_error (&error);
g_object_unref (result); g_object_unref (result);
} }
@ -815,6 +817,7 @@ test_delete_sync (Test *test,
item = secret_item_new_for_dbus_path_sync (test->service, item_path, SECRET_ITEM_NONE, NULL, &error); item = secret_item_new_for_dbus_path_sync (test->service, item_path, SECRET_ITEM_NONE, NULL, &error);
g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD); g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD);
g_assert (item == NULL); g_assert (item == NULL);
g_clear_error (&error);
} }
static void static void
@ -845,6 +848,7 @@ test_delete_async (Test *test,
item = secret_item_new_for_dbus_path_sync (test->service, item_path, SECRET_ITEM_NONE, NULL, &error); item = secret_item_new_for_dbus_path_sync (test->service, item_path, SECRET_ITEM_NONE, NULL, &error);
g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD); g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD);
g_assert (item == NULL); g_assert (item == NULL);
g_clear_error (&error);
} }
int int