Blob Blame History Raw
From bb381997525a1ff74f1bbac3556d566b62f3ef1b Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Wed, 27 Sep 2017 10:41:47 -0400
Subject: [PATCH 02/13] lib: leak fix

If a new user is added by accounts service, we currently leak
a reference to it. That leads to transient user objects living
longer than they're supposed which uses memory and produces
excess bus traffic.
---
 src/libaccountsservice/act-user-manager.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/libaccountsservice/act-user-manager.c b/src/libaccountsservice/act-user-manager.c
index d866725..c8d0443 100644
--- a/src/libaccountsservice/act-user-manager.c
+++ b/src/libaccountsservice/act-user-manager.c
@@ -1088,68 +1088,71 @@ add_new_user_for_object_path (const char     *object_path,
         user = g_hash_table_lookup (manager->priv->users_by_object_path, object_path);
 
         if (user != NULL) {
                 g_debug ("ActUserManager: tracking existing %s with object path %s",
                          describe_user (user), object_path);
                 return user;
         }
 
         user = find_new_user_with_object_path (manager, object_path);
 
         if (user != NULL) {
                 g_debug ("ActUserManager: tracking existing (but very recently added) %s with object path %s",
                          describe_user (user), object_path);
                 return user;
         }
 
         g_debug ("ActUserManager: tracking new user with object path %s", object_path);
 
         user = create_new_user (manager);
         _act_user_update_from_object_path (user, object_path);
 
         return user;
 }
 
 static void
 on_new_user_in_accounts_service (GDBusProxy *proxy,
                                  const char *object_path,
                                  gpointer    user_data)
 {
         ActUserManager *manager = ACT_USER_MANAGER (user_data);
+        ActUser *user;
 
         if (!manager->priv->is_loaded) {
                 g_debug ("ActUserManager: ignoring new user in accounts service with object path %s since not loaded yet", object_path);
                 return;
         }
 
         g_debug ("ActUserManager: new user in accounts service with object path %s", object_path);
-        add_new_user_for_object_path (object_path, manager);
+        user = add_new_user_for_object_path (object_path, manager);
+
+        g_object_unref (user);
 }
 
 static void
 on_user_removed_in_accounts_service (GDBusProxy *proxy,
                                      const char *object_path,
                                      gpointer    user_data)
 {
         ActUserManager *manager = ACT_USER_MANAGER (user_data);
         ActUser        *user;
 
         user = g_hash_table_lookup (manager->priv->users_by_object_path, object_path);
 
         if (user == NULL) {
                 g_debug ("ActUserManager: ignoring untracked user %s", object_path);
                 return;
         } else {
                 g_debug ("ActUserManager: tracked user %s removed from accounts service", object_path);
         }
 
         manager->priv->new_users = g_slist_remove (manager->priv->new_users, user);
 
         remove_user (manager, user);
 }
 
 static void
 on_get_current_session_finished (GObject        *object,
                                  GAsyncResult   *result,
                                  gpointer        data)
 {
         ConsoleKitManager *proxy = CONSOLE_KIT_MANAGER (object);
-- 
2.14.1