[Telepathy-commits] [telepathy-mission-control/master] Make sure the channel list is always consistent

Alberto Mardegan alberto.mardegan at nokia.com
Fri Dec 5 00:13:49 PST 2008


Move the mcd_operation_get_missions() call inside the loop, because
mcd_dispatcher_send() can cause the channel to be destroyed, and when that
happened our list contained a finalized channel (and a crash did happen)
---
 src/mcd-connection.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/mcd-connection.c b/src/mcd-connection.c
index 3e1e071..7d76a53 100644
--- a/src/mcd-connection.c
+++ b/src/mcd-connection.c
@@ -1279,7 +1279,6 @@ static void get_all_requests_cb (TpProxy *proxy, GHashTable *properties,
 {
     McdConnection *connection = MCD_CONNECTION (weak_object);
     McdConnectionPrivate *priv = user_data;
-    const GList *mcd_channels, *list;
     GPtrArray *channels;
     GValue *value;
     guint i;
@@ -1299,19 +1298,24 @@ static void get_all_requests_cb (TpProxy *proxy, GHashTable *properties,
         return;
     }
 
-    mcd_channels = mcd_operation_get_missions ((McdOperation *)connection);
     channels = g_value_get_boxed (value);
     for (i = 0; i < channels->len; i++)
     {
         GValueArray *va;
         const gchar *object_path;
         GHashTable *channel_props;
+        const GList *list;
 
         va = g_ptr_array_index (channels, i);
         object_path = g_value_get_boxed (va->values);
         channel_props = g_value_dup_boxed (va->values + 1);
         /* find the McdChannel */
-        for (list = mcd_channels; list != NULL; list = list->next)
+        /* NOTE: we cannot move the mcd_operation_get_missions() call out of
+         * the loop, because mcd_dispatcher_send() can cause the channel to be
+         * destroyed, at which point our list would contain a finalized channel
+         * (and a crash will happen) */
+        list = mcd_operation_get_missions ((McdOperation *)connection);
+        for (; list != NULL; list = list->next)
         {
             McdChannel *channel = MCD_CHANNEL (list->data);
             const gchar *channel_path;
-- 
1.5.6.5




More information about the Telepathy-commits mailing list