From 90e2199ac99f5b8ab0cd5f45dcb398ecf9af03d9 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Sat, 12 Sep 2009 11:58:22 +0100 Subject: [PATCH] Copy object registration list when unregistering. Since the list of registrations on the object is modified when each path is removed, iterating it directly is wrong: after the first pass of the loop, 'iter' would point to a link which has been freed. --- dbus/dbus-gobject.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/dbus/dbus-gobject.c b/dbus/dbus-gobject.c index 85574c7..816194c 100644 --- a/dbus/dbus-gobject.c +++ b/dbus/dbus-gobject.c @@ -2117,7 +2117,10 @@ dbus_g_connection_unregister_g_object (DBusGConnection *connection, { GList *registrations, *iter; - registrations = g_object_get_data (object, "dbus_glib_object_registrations"); + /* Copy the list before iterating it: it will be modified in + * object_registration_free() each time an object path is unregistered. + */ + registrations = g_list_copy (g_object_get_data (object, "dbus_glib_object_registrations")); g_return_if_fail (registrations != NULL); @@ -2127,6 +2130,9 @@ dbus_g_connection_unregister_g_object (DBusGConnection *connection, dbus_connection_unregister_object_path (DBUS_CONNECTION_FROM_G_CONNECTION (o->connection), o->object_path); } + + g_list_free (registrations); + g_assert (g_object_get_data (object, "dbus_glib_object_registrations") == NULL); } /** -- 1.6.3.3