From: Alberto Mardegan Date: Thu, 29 Nov 2012 11:58:06 +0000 (+0200) Subject: Fix all memory leaks detected by valgrind X-Git-Tag: 1.8~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2666ec999b4c24b74fd3e9d0c122812cd1329e5a;p=platform%2Fupstream%2Flibgsignon-glib.git Fix all memory leaks detected by valgrind --- diff --git a/libsignon-glib/signon-auth-service.c b/libsignon-glib/signon-auth-service.c index 444227b..3c8db43 100644 --- a/libsignon-glib/signon-auth-service.c +++ b/libsignon-glib/signon-auth-service.c @@ -144,7 +144,7 @@ auth_query_methods_cb (GObject *object, GAsyncResult *res, (data->cb) (data->service, value, error, data->userdata); - g_free (value); + g_strfreev (value); if (error) g_error_free (error); g_slice_free (MethodCbData, data); @@ -166,7 +166,7 @@ auth_query_mechanisms_cb (GObject *object, GAsyncResult *res, (data->cb) (data->service, data->method, value, error, data->userdata); - g_free (value); + g_strfreev (value); if (error) g_error_free (error); g_free (data->method); diff --git a/libsignon-glib/signon-auth-session.c b/libsignon-glib/signon-auth-session.c index 488323e..c896ab5 100644 --- a/libsignon-glib/signon-auth-session.c +++ b/libsignon-glib/signon-auth-session.c @@ -530,6 +530,7 @@ auth_session_get_object_path_reply (GObject *object, GAsyncResult *res, } DEBUG ("Object path received: %s", object_path); + g_free (object_path); _signon_object_ready (self, auth_session_object_quark (), error); g_clear_error (&error); } diff --git a/libsignon-glib/signon-identity.c b/libsignon-glib/signon-identity.c index cdf7dca..2e0989f 100644 --- a/libsignon-glib/signon-identity.c +++ b/libsignon-glib/signon-identity.c @@ -478,7 +478,7 @@ identity_new_cb (GObject *object, GAsyncResult *res, { SignonIdentity *identity = (SignonIdentity*)userdata; SsoAuthService *proxy = SSO_AUTH_SERVICE (object); - gchar *object_path; + gchar *object_path = NULL; GError *error = NULL; g_return_if_fail (identity != NULL); @@ -490,6 +490,7 @@ identity_new_cb (GObject *object, GAsyncResult *res, &error); SIGNON_RETURN_IF_CANCELLED (error); identity_registered (identity, object_path, NULL, error); + g_free (object_path); } static void @@ -498,7 +499,7 @@ identity_new_from_db_cb (GObject *object, GAsyncResult *res, { SignonIdentity *identity = (SignonIdentity*)userdata; SsoAuthService *proxy = SSO_AUTH_SERVICE (object); - gchar *object_path; + gchar *object_path = NULL; GVariant *identity_data; GError *error = NULL; @@ -512,6 +513,7 @@ identity_new_from_db_cb (GObject *object, GAsyncResult *res, &error); SIGNON_RETURN_IF_CANCELLED (error); identity_registered (identity, object_path, identity_data, error); + g_free (object_path); } static void diff --git a/tests/check_signon.c b/tests/check_signon.c index 957db3d..d67ffa1 100644 --- a/tests/check_signon.c +++ b/tests/check_signon.c @@ -358,6 +358,8 @@ START_TEST(test_auth_session_query_mechanisms_nonexisting) g_main_loop_run (main_loop); g_free(patterns[0]); + g_free(patterns[1]); + g_free(patterns[2]); g_object_unref(idty); end_test (); @@ -479,8 +481,7 @@ START_TEST(test_auth_session_process) "mech1", test_auth_session_process_cb, sessionData); - if(!main_loop) - main_loop = g_main_loop_new (NULL, FALSE); + main_loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (main_loop); @@ -518,7 +519,7 @@ START_TEST(test_auth_session_process) g_free(passwordVa); g_free(passwordKey); - + end_test (); } END_TEST @@ -666,9 +667,6 @@ new_identity() GHashTable *methods; guint id = 0; - if (main_loop == NULL) - main_loop = g_main_loop_new (NULL, FALSE); - identity = signon_identity_new(NULL, NULL); fail_unless (SIGNON_IS_IDENTITY (identity)); methods = g_hash_table_new (g_str_hash, g_str_equal); @@ -704,6 +702,8 @@ START_TEST(test_get_existing_identity) g_type_init (); g_debug("%s", G_STRFUNC); + + main_loop = g_main_loop_new (NULL, FALSE); guint id = new_identity(); fail_unless (id != 0); @@ -715,7 +715,6 @@ START_TEST(test_get_existing_identity) "Failed to initialize the Identity."); g_timeout_add (1000, identity_registered_cb, identity); - main_loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (main_loop); end_test (); @@ -785,6 +784,7 @@ START_TEST(test_store_credentials_identity) fail_unless (SIGNON_IS_IDENTITY (idty), "Failed to initialize the Identity."); + main_loop = g_main_loop_new (NULL, FALSE); gint last_id = new_identity(); GHashTable *methods = create_methods_hashtable(); @@ -803,7 +803,6 @@ START_TEST(test_store_credentials_identity) g_hash_table_destroy (methods); g_timeout_add (1000, test_quit_main_loop_cb, idty); - main_loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (main_loop); g_object_unref(idty); @@ -1218,6 +1217,8 @@ START_TEST(test_signout_identity) g_object_unref (idty); g_object_unref (idty2); + + end_test (); } END_TEST @@ -1255,6 +1256,8 @@ START_TEST(test_unregistered_identity) g_object_unref (idty); g_object_unref (idty2); + + end_test (); } END_TEST @@ -1368,8 +1371,10 @@ START_TEST(test_regression_unref) session_data, "mech1", test_regression_unref_process_cb, - g_strdup ("Hi there!")); + "Hi there!"); g_main_loop_run (main_loop); + + end_test (); } END_TEST