1
commit f36381131b6f410333a9a823a4fc131ac799394f
2
Author: Simon McVittie <simon.mcvittie@collabora.co.uk>
3
Date: 2009-03-26 18:00:16 +0000
5
fd.o#20884: dbus_g_proxy_manager_replace_name_owner: don't leave freed memory in the hash table if the name was the owner's first
7
Here's a situation where this code would fail:
9
* an owner :1.42 owns a name com.Example and a name org.Example
10
* the owner_names hash table contains { :1.42 => c }, where
11
c is a GSList link with data = "com.Example", next = o and
12
o is a GSList link with data = "org.Example", next = NULL
13
* the name owner for com.Example changes so :1.42 no longer owns the
15
* initially, names == c
16
* g_slist_delete_link unlinks and frees c, and sets names = o
17
* but c is still in the hash table, so next time we look in the hash
20
The fix is to replace c with o in the owner_names hash table.
22
diff --git a/dbus/dbus-gproxy.c b/dbus/dbus-gproxy.c
23
index b379c20..572b7fb 100644
24
--- a/dbus/dbus-gproxy.c
25
+++ b/dbus/dbus-gproxy.c
26
@@ -753,9 +753,16 @@ dbus_g_proxy_manager_replace_name_owner (DBusGProxyManager *manager,
28
names = g_slist_delete_link (names, link);
31
- g_hash_table_remove (manager->owner_names, prev_owner);
35
+ g_hash_table_remove (manager->owner_names, prev_owner);
39
+ g_hash_table_insert (manager->owner_names,
40
+ g_strdup (prev_owner), names);
45
if (new_owner[0] == '\0')