comparison libpurple/protocols/oscar/flap_connection.c @ 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 38cc722159ff
children 23d85a181575
comparison
equal deleted inserted replaced
22164:d1fe81e3a850 22165:5421a1dc36f6
30 #endif 30 #endif
31 31
32 #ifdef _WIN32 32 #ifdef _WIN32
33 #include "win32dep.h" 33 #include "win32dep.h"
34 #endif 34 #endif
35
36 static GList *flap_connections = NULL;
37 #define PURPLE_FLAP_CONNECTION_IS_VALID(conn) (g_list_find(flap_connections, (conn)) != NULL)
35 38
36 /** 39 /**
37 * This sends a channel 1 SNAC containing the FLAP version. 40 * This sends a channel 1 SNAC containing the FLAP version.
38 * The FLAP version is sent by itself at the beginning of every 41 * The FLAP version is sent by itself at the beginning of every
39 * connection to a FLAP server. It is always the very first 42 * connection to a FLAP server. It is always the very first
271 conn->subtype = -1; 274 conn->subtype = -1;
272 conn->type = type; 275 conn->type = type;
273 conn->queued_snacs = g_queue_new(); 276 conn->queued_snacs = g_queue_new();
274 277
275 od->oscar_connections = g_slist_prepend(od->oscar_connections, conn); 278 od->oscar_connections = g_slist_prepend(od->oscar_connections, conn);
279 flap_connections = g_list_append(flap_connections, conn);
276 280
277 return conn; 281 return conn;
278 } 282 }
279 283
280 /** 284 /**
357 OscarData *od; 361 OscarData *od;
358 PurpleAccount *account; 362 PurpleAccount *account;
359 aim_rxcallback_t userfunc; 363 aim_rxcallback_t userfunc;
360 364
361 conn = data; 365 conn = data;
366
367 if (!PURPLE_FLAP_CONNECTION_IS_VALID(conn))
368 return FALSE;
369
362 od = conn->od; 370 od = conn->od;
363 account = (PURPLE_CONNECTION_IS_VALID(od->gc) ? purple_connection_get_account(od->gc) : NULL); 371 account = (PURPLE_CONNECTION_IS_VALID(od->gc) ? purple_connection_get_account(od->gc) : NULL);
364 372
365 purple_debug_info("oscar", "Destroying oscar connection of " 373 purple_debug_info("oscar", "Destroying oscar connection of "
366 "type 0x%04hx. Disconnect reason is %d\n", 374 "type 0x%04hx. Disconnect reason is %d\n",
438 } 446 }
439 g_queue_free(conn->queued_snacs); 447 g_queue_free(conn->queued_snacs);
440 if (conn->queued_timeout > 0) 448 if (conn->queued_timeout > 0)
441 purple_timeout_remove(conn->queued_timeout); 449 purple_timeout_remove(conn->queued_timeout);
442 450
451 flap_connections = g_list_remove(flap_connections, conn);
452
443 g_free(conn); 453 g_free(conn);
444 454
445 return FALSE; 455 return FALSE;
446 } 456 }
447 457