telepathy-gabble: server-tls-manager: deal with modification of the GList while iterating it

Jonny Lamb jonny at kemper.freedesktop.org
Wed Jul 11 06:43:00 PDT 2012


Module: telepathy-gabble
Branch: master
Commit: 5de7189fa93918cc1dda3bfdf8d5833b63e43020
URL:    http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=5de7189fa93918cc1dda3bfdf8d5833b63e43020

Author: Jonny Lamb <jonny.lamb at collabora.co.uk>
Date:   Wed Jul 11 11:53:03 2012 +0100

server-tls-manager: deal with modification of the GList while iterating it

Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>

---

 src/server-tls-manager.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/server-tls-manager.c b/src/server-tls-manager.c
index 87969cc..4e961cd 100644
--- a/src/server-tls-manager.c
+++ b/src/server-tls-manager.c
@@ -123,8 +123,17 @@ close_all (GabbleServerTLSManager *self)
   if (self->priv->channel != NULL)
     tp_base_channel_close (TP_BASE_CHANNEL (self->priv->channel));
 
-  for (l = self->priv->completed_channels; l != NULL; l = l->next)
-    tp_base_channel_close (l->data);
+  l = self->priv->completed_channels;
+  while (l != NULL)
+    {
+      /* use a temporary variable as the ::closed callback will delete
+       * the link from the list. */
+      GList *next = l->next;
+
+      tp_base_channel_close (l->data);
+
+      l = next;
+    }
 }
 
 static void



More information about the telepathy-commits mailing list