[telepathy-mission-control/master] Don't touch dead channels

Alberto Mardegan alberto.mardegan at nokia.com
Thu May 7 09:42:01 PDT 2009


The call_data structure carries a list of McdChannels, but doesn't hold a
reference to them; they could die before HandleChannels returns, and in that
case we must not access them.
---
 src/mcd-dispatcher.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index 29f7447..c9dee00 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -613,7 +613,12 @@ handle_channels_cb (TpProxy *proxy, const GError *error, gpointer user_data,
 
         for (list = call_data->channels; list != NULL; list = list->next)
         {
-            McdChannel *channel = MCD_CHANNEL (list->data);
+            McdChannel *channel = list->data;
+
+            /* if the channel is no longer in the context, don't even try to
+             * access it */
+            if (!g_list_find (context->channels, channel))
+                continue;
 
             mcd_channel_take_error (channel, g_error_copy (mc_error));
             g_signal_emit_by_name (context->dispatcher, "dispatch-failed",
@@ -629,7 +634,12 @@ handle_channels_cb (TpProxy *proxy, const GError *error, gpointer user_data,
     {
         for (list = call_data->channels; list != NULL; list = list->next)
         {
-            McdChannel *channel = MCD_CHANNEL (list->data);
+            McdChannel *channel = list->data;
+
+            /* if the channel is no longer in the context, don't even try to
+             * access it */
+            if (!g_list_find (context->channels, channel))
+                continue;
 
             /* TODO: abort the channel if the handler dies */
             _mcd_channel_set_status (channel, MCD_CHANNEL_STATUS_DISPATCHED);
-- 
1.5.6.5




More information about the telepathy-commits mailing list