[gdm] Don't leak result of g_dbus_connection_new_for_address_finish()



commit 8bb0fbb02a3367b4d5f716dc71aebec401a11297
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Thu Oct 9 12:27:21 2014 -0400

    Don't leak result of g_dbus_connection_new_for_address_finish()
    
    g_dbus_connection_new_for_address_finish() returns a new reference;
    we can't simply ignore the returned connection, even though it is also
    passed in as the source object of the GAsyncReadyCallback.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=738246

 libgdm/gdm-client.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/libgdm/gdm-client.c b/libgdm/gdm-client.c
index 168eabd..1f42891 100644
--- a/libgdm/gdm-client.c
+++ b/libgdm/gdm-client.c
@@ -169,15 +169,17 @@ on_user_verifier_proxy_created (GObject            *source,
 }
 
 static void
-on_reauthentication_channel_connected (GDBusConnection    *connection,
+on_reauthentication_channel_connected (GObject            *source_object,
                                        GAsyncResult       *result,
                                        GSimpleAsyncResult *operation_result)
 {
+        GDBusConnection *connection;
         GCancellable *cancellable;
         GError       *error;
 
         error = NULL;
-        if (!g_dbus_connection_new_for_address_finish (result, &error)) {
+        connection = g_dbus_connection_new_for_address_finish (result, &error);
+        if (!connection) {
                 g_simple_async_result_take_error (operation_result, error);
                 g_simple_async_result_complete_in_idle (operation_result);
                 g_object_unref (operation_result);
@@ -193,6 +195,7 @@ on_reauthentication_channel_connected (GDBusConnection    *connection,
                                      (GAsyncReadyCallback)
                                      on_user_verifier_proxy_created,
                                      operation_result);
+        g_object_unref (connection);
 }
 
 static void
@@ -311,15 +314,16 @@ gdm_client_open_connection_sync (GdmClient      *client,
 }
 
 static void
-on_connected (GDBusConnection    *connection,
+on_connected (GObject            *source_object,
               GAsyncResult       *result,
               GSimpleAsyncResult *operation_result)
 {
+        GDBusConnection *connection;
         GError *error;
 
         error = NULL;
-        if (!g_dbus_connection_new_for_address_finish (result,
-                                                       &error)) {
+        connection = g_dbus_connection_new_for_address_finish (result, &error);
+        if (!connection) {
                 g_simple_async_result_take_error (operation_result, error);
                 g_simple_async_result_complete_in_idle (operation_result);
                 g_object_unref (operation_result);
@@ -332,6 +336,7 @@ on_connected (GDBusConnection    *connection,
                                                    g_object_unref);
         g_simple_async_result_complete_in_idle (operation_result);
         g_object_unref (operation_result);
+        g_object_unref (connection);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]