changeset 19233:6e3cd5e80420

Don't trigger another libxml2 parse from within one of the parsing callbacks. References #1652.
author Daniel Atallah <daniel.atallah@gmail.com>
date Mon, 13 Aug 2007 21:02:17 +0000
parents 03d81500766d
children 771423734d6a
files libpurple/protocols/bonjour/jabber.c libpurple/protocols/bonjour/parser.c
diffstat 2 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/bonjour/jabber.c	Mon Aug 13 06:24:47 2007 +0000
+++ b/libpurple/protocols/bonjour/jabber.c	Mon Aug 13 21:02:17 2007 +0000
@@ -371,6 +371,8 @@
 
 	purple_debug_info("bonjour", "Recieved conversation close notification from %s.\n", pb->name);
 
+	g_return_if_fail(bb != NULL);
+
 	/* Close the socket, clear the watcher and free memory */
 	bonjour_jabber_close_conversation(bb->conversation);
 	bb->conversation = NULL;
--- a/libpurple/protocols/bonjour/parser.c	Mon Aug 13 06:24:47 2007 +0000
+++ b/libpurple/protocols/bonjour/parser.c	Mon Aug 13 21:02:17 2007 +0000
@@ -82,6 +82,11 @@
 	}
 }
 
+static gboolean _async_bonjour_jabber_stream_ended_cb(gpointer data) {
+	bonjour_jabber_stream_ended((PurpleBuddy *) data);
+	return FALSE;
+}
+
 static void
 bonjour_parser_element_end_libxml(void *user_data, const xmlChar *element_name,
 				 const xmlChar *prefix, const xmlChar *namespace)
@@ -94,7 +99,9 @@
 		/* We don't keep a reference to the start stream xmlnode,
 		 * so we have to check for it here to close the conversation */
 		if(!xmlStrcmp(element_name, (xmlChar*) "stream")) {
-			bonjour_jabber_stream_ended(pb);
+			/* Asynchronously close the conversation to prevent bonjour_parser_setup()
+			 * being called from within this context */
+			g_idle_add(_async_bonjour_jabber_stream_ended_cb, pb);
 		}
 		return;
 	}