From 5c222582b2f049ac00dd0e75f934c2d4c9383072 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Fri, 19 Sep 2014 11:36:37 -0400 Subject: lib: make sure replace key when replacing value in object_path hash If add_user gets called on user object that's already being tracked by object path, we can end up replacing and freeing the user object but leaving the old object path memory in the hash table. This commit makes sure we replace the key when replacing the object. --- src/libaccountsservice/act-user-manager.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libaccountsservice/act-user-manager.c b/src/libaccountsservice/act-user-manager.c index c1c6f5a..948179e 100644 --- a/src/libaccountsservice/act-user-manager.c +++ b/src/libaccountsservice/act-user-manager.c @@ -869,9 +869,9 @@ add_user (ActUserManager *manager, object_path = act_user_get_object_path (user); if (object_path != NULL) { - g_hash_table_insert (manager->priv->users_by_object_path, - (gpointer) object_path, - g_object_ref (user)); + g_hash_table_replace (manager->priv->users_by_object_path, + (gpointer) object_path, + g_object_ref (user)); } g_signal_connect_object (user, -- cgit v1.2.3