summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2014-09-19 11:36:37 -0400
committerRay Strode <rstrode@redhat.com>2014-09-19 11:37:58 -0400
commit5c222582b2f049ac00dd0e75f934c2d4c9383072 (patch)
treeb902ea09473a17bf10e3027267b0c6598ae8a64b
parent7ef30275c7ab6d175b1735d95b185cb13bbe1fd6 (diff)
downloadaccountsservice-5c222582b2f049ac00dd0e75f934c2d4c9383072.tar.gz
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.
-rw-r--r--src/libaccountsservice/act-user-manager.c6
1 files 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,