From: Ray Strode Date: Sat, 21 Jan 2012 11:06:27 +0000 (-0600) Subject: bridge: drive-by list usage fixes X-Git-Tag: AT_SPI2_ATK_2_12_0~158 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git;a=commitdiff_plain;h=247aaaa35739a8ab5e342be6ce4de11d26142b6f;hp=631f89c9561d319f5f7b488ddbd8cbb1d1f4d684 bridge: drive-by list usage fixes There are a few places where the glib list apis aren't being used right: 1) There is code that use GList functions on GSLists 2) There is code that uses the list node itself instead of the node data 3) There is code that removes nodes from a list as its iterating over that list. https://bugzilla.gnome.org/show_bug.cgi?id=659967 --- diff --git a/atk-adaptor/bridge.c b/atk-adaptor/bridge.c index 3d10e9b..08e72fc 100644 --- a/atk-adaptor/bridge.c +++ b/atk-adaptor/bridge.c @@ -975,14 +975,18 @@ gnome_accessibility_module_shutdown (void) for (l = spi_global_app_data->direct_connections; l; l = l->next) { - droute_context_unregister (spi_global_app_data->droute, l->data); - droute_unintercept_dbus (l->data); - dbus_connection_unref (l->data); + DBusConnection *connection; + + connection = l->data; + + droute_context_unregister (spi_global_app_data->droute, connection); + droute_unintercept_dbus (connection); + dbus_connection_unref (connection); } g_list_free (spi_global_app_data->direct_connections); for (ls = clients; ls; ls = ls->next) - g_free (l->data); + g_free (l->data); g_slist_free (clients); clients = NULL; @@ -1031,19 +1035,25 @@ void spi_atk_remove_client (const char *bus_name) { GSList *l; + GSList *next_node; - for (l = clients; l; l = l->next) + l = clients; + while (l) { + next_node = l->next; + if (!g_strcmp0 (l->data, bus_name)) { gchar *match = g_strdup_printf (name_match_tmpl, l->data); dbus_bus_remove_match (spi_global_app_data->bus, match, NULL); g_free (match); g_free (l->data); - clients = g_slist_remove_link (clients, l); + clients = g_slist_delete_link (clients, l); if (!clients) spi_atk_deregister_event_listeners (); } + + l = next_node; } }