changeset 22165:5421a1dc36f6

Track validity of flap_connections to prevent a crash when a disconnect is initiated via purple_timeout_add in flap_connection_schedule_destroy() and then is subsequently destroyed before the timeout is actually called.
author Evan Schoenberg <evan.s@dreskin.net>
date Sun, 20 Jan 2008 20:52:45 +0000
parents d1fe81e3a850
children 23d85a181575
files libpurple/protocols/oscar/flap_connection.c
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/oscar/flap_connection.c	Sun Jan 20 13:54:26 2008 +0000
+++ b/libpurple/protocols/oscar/flap_connection.c	Sun Jan 20 20:52:45 2008 +0000
@@ -33,6 +33,9 @@
 #include "win32dep.h"
 #endif
 
+static GList *flap_connections = NULL;
+#define PURPLE_FLAP_CONNECTION_IS_VALID(conn) (g_list_find(flap_connections, (conn)) != NULL)
+
 /**
  * This sends a channel 1 SNAC containing the FLAP version.
  * The FLAP version is sent by itself at the beginning of every
@@ -273,6 +276,7 @@
 	conn->queued_snacs = g_queue_new();
 
 	od->oscar_connections = g_slist_prepend(od->oscar_connections, conn);
+	flap_connections = g_list_append(flap_connections, conn);
 
 	return conn;
 }
@@ -359,6 +363,10 @@
 	aim_rxcallback_t userfunc;
 
 	conn = data;
+	
+	if (!PURPLE_FLAP_CONNECTION_IS_VALID(conn))
+		return FALSE;
+
 	od = conn->od;
 	account = (PURPLE_CONNECTION_IS_VALID(od->gc) ? purple_connection_get_account(od->gc) : NULL);
 
@@ -440,6 +448,8 @@
 	if (conn->queued_timeout > 0)
 		purple_timeout_remove(conn->queued_timeout);
 
+	flap_connections = g_list_remove(flap_connections, conn);
+
 	g_free(conn);
 
 	return FALSE;