[Telepathy-commits] [telepathy-gabble/master] Release weak ref before calling into user code in GabbleDisco, to avoid crashes if the user code causes the weakly reffed object to be destroyed

Simon McVittie simon.mcvittie at collabora.co.uk
Tue Aug 19 10:52:04 PDT 2008


20080501180447-53eee-0ced607caecb1143a9f95c8fe4292d86dc5ec6ee.gz
---
 src/disco.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/disco.c b/src/disco.c
index 4dd00c1..b7dab2d 100644
--- a/src/disco.c
+++ b/src/disco.c
@@ -306,6 +306,15 @@ timeout_request (gpointer data)
    * destroys us (as seen in test-disco-no-reply.py) */
   disco = g_object_ref (request->disco);
 
+  /* also, we're about to run the callback, so it's too late to cancel it -
+   * avoid crashing if running the callback destroys the bound object */
+  if (NULL != request->bound_object)
+    {
+      g_object_weak_unref (request->bound_object, notify_delete_request,
+          request);
+      request->bound_object = NULL;
+    }
+
   (request->callback)(request->disco, request, request->jid, request->node,
                       NULL, err, request->user_data);
   g_error_free (err);
-- 
1.5.6.3




More information about the Telepathy-commits mailing list