[gnome-keyring/wip/gdbus: 6/9] dbus: plug some memory leaks



commit 3cbcaf316af95d0b687d29fea0269ff7132edb7d
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Nov 14 13:43:33 2014 -0800

    dbus: plug some memory leaks

 daemon/dbus/gkd-dbus-session.c    |   45 +++++++++++++++++++++---------------
 daemon/dbus/gkd-secret-property.c |    8 +++++-
 2 files changed, 32 insertions(+), 21 deletions(-)
---
diff --git a/daemon/dbus/gkd-dbus-session.c b/daemon/dbus/gkd-dbus-session.c
index e979aa1..8d5033c 100644
--- a/daemon/dbus/gkd-dbus-session.c
+++ b/daemon/dbus/gkd-dbus-session.c
@@ -43,31 +43,36 @@ send_end_session_response (GDBusConnection *conn)
        const gchar *reason = "";
        gboolean is_ok = TRUE;
        GError *error = NULL;
+       GVariant *res;
 
        g_return_if_fail (client_session_path);
 
-       g_dbus_connection_call_sync (conn,
-                                    SERVICE_SESSION_MANAGER,
-                                    client_session_path,
-                                    IFACE_SESSION_PRIVATE,
-                                    "EndSessionResponse",
-                                    g_variant_new ("(bs)",
-                                                   is_ok,
-                                                   reason),
-                                    NULL,
-                                    G_DBUS_CALL_FLAGS_NONE, 1000,
-                                    NULL, &error);
+       res = g_dbus_connection_call_sync (conn,
+                                          SERVICE_SESSION_MANAGER,
+                                          client_session_path,
+                                          IFACE_SESSION_PRIVATE,
+                                          "EndSessionResponse",
+                                          g_variant_new ("(bs)",
+                                                         is_ok,
+                                                         reason),
+                                          NULL,
+                                          G_DBUS_CALL_FLAGS_NONE, 1000,
+                                          NULL, &error);
 
        if (error != NULL) {
                g_message ("dbus failure responding to ending session: %s", error->message);
                g_error_free (error);
                return;
        }
+
+       g_variant_unref (res);
 }
 
 static void
 unregister_daemon_in_session (GDBusConnection *conn)
 {
+       GVariant *res;
+
        if (client_session_signal_id) {
                g_dbus_connection_signal_unsubscribe (conn, client_session_signal_id);
                client_session_signal_id = 0;
@@ -76,17 +81,19 @@ unregister_daemon_in_session (GDBusConnection *conn)
        if (!client_session_path)
                return;
 
-       g_dbus_connection_call_sync (conn,
-                                    SERVICE_SESSION_MANAGER,
-                                    PATH_SESSION_MANAGER,
-                                    IFACE_SESSION_MANAGER,
-                                    "UnregisterClient",
-                                    g_variant_new ("(o)", client_session_path),
-                                    NULL, G_DBUS_CALL_FLAGS_NONE,
-                                    -1, NULL, NULL);
+       res = g_dbus_connection_call_sync (conn,
+                                          SERVICE_SESSION_MANAGER,
+                                          PATH_SESSION_MANAGER,
+                                          IFACE_SESSION_MANAGER,
+                                          "UnregisterClient",
+                                          g_variant_new ("(o)", client_session_path),
+                                          NULL, G_DBUS_CALL_FLAGS_NONE,
+                                          -1, NULL, NULL);
 
        g_free (client_session_path);
        client_session_path = NULL;
+
+       g_clear_pointer (&res, g_variant_unref);
 }
 
 static void
diff --git a/daemon/dbus/gkd-secret-property.c b/daemon/dbus/gkd-secret-property.c
index 9c30d80..3be7f6a 100644
--- a/daemon/dbus/gkd-secret-property.c
+++ b/daemon/dbus/gkd-secret-property.c
@@ -457,14 +457,18 @@ gkd_secret_property_parse_all (GVariant *array,
 
         g_variant_iter_init (&iter, array);
 
-       while (g_variant_iter_loop (&iter, "{sv}", &name, &variant)) {
+       while (g_variant_iter_next (&iter, "{&sv}", &name, &variant)) {
                /* Property interface.name */
                if (!property_to_attribute (name, interface, &attr_type, &data_type))
                        return FALSE;
 
                /* Property value */
-               if (!iter_get_variant (variant, data_type, attr_type, builder))
+               if (!iter_get_variant (variant, data_type, attr_type, builder)) {
+                       g_variant_unref (variant);
                        return FALSE;
+               }
+
+               g_variant_unref (variant);
        }
 
        return TRUE;


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