changeset 26256:cda9031ecabc

Clean up Jabber's references and protocol_data if the window is closed
author Paul Aurich <paul@darkrain42.org>
date Tue, 31 Mar 2009 05:40:13 +0000
parents de05bdd931ed
children ce23e32a0ada
files libpurple/protocols/jabber/disco.c
diffstat 1 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/disco.c	Tue Mar 31 05:22:44 2009 +0000
+++ b/libpurple/protocols/jabber/disco.c	Tue Mar 31 05:40:13 2009 +0000
@@ -655,6 +655,13 @@
 
 	--list_data->fetch_count;
 
+	if (list_data->list == NULL) {
+		if (list_data->fetch_count == 0)
+			jabber_disco_list_data_destroy(list_data);
+
+		return;
+	}
+
 	if (!from || !result || !query || strcmp(result, "result") != 0) {
 		if (list_data->fetch_count == 0)
 			purple_disco_list_set_in_progress(list, FALSE);
@@ -743,6 +750,13 @@
 
 	--list_data->fetch_count;
 
+	if (list_data->list == NULL) {
+		if (list_data->fetch_count == 0)
+			jabber_disco_list_data_destroy(list_data);
+
+		return;
+	}
+
 	if (!from || !result || strcmp(result, "result") != 0
 			|| (!(query = xmlnode_get_child(packet, "query")))
 			|| (!(ident = xmlnode_get_child(query, "identity")))) {
@@ -981,9 +995,16 @@
 	if (list_data->fetch_count == 0) {
 		/* Nothing outstanding, just free it now... */
 		jabber_disco_list_data_destroy(list_data);
-	} else
-		/* We'll free it when the count is 0 */
+	} else {
+		int i;
+		/* Lose all our references to the PurpleDiscoList */
+		for (i = 0; i < list_data->fetch_count; ++i) {
+			purple_disco_list_unref(list);
+		}
+
+		/* We'll free list_data when fetch_count is down to 0 */
 		list_data->list = NULL;
+	}
 }
 
 int