changeset 30088:e432507151d1

NULL-ify some reverse links so that there's no double-free on exit.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sun, 23 May 2010 21:45:19 +0000
parents a4527d9ee853
children 287fc4ac2bd9
files libpurple/protocols/msn/directconn.c libpurple/protocols/msn/slplink.c
diffstat 2 files changed, 16 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/directconn.c	Sun May 23 17:26:20 2010 +0000
+++ b/libpurple/protocols/msn/directconn.c	Sun May 23 21:45:19 2010 +0000
@@ -169,15 +169,15 @@
 
 	g_return_if_fail(dc != NULL);
 
-	slplink = dc->slplink;
-
 	if (dc->slpcall != NULL)
 		dc->slpcall->wait_for_socket = FALSE;
 
-	slplink->dc = NULL;
-
-	if (slplink->swboard == NULL)
-		msn_slplink_destroy(slplink);
+	slplink = dc->slplink;
+	if (slplink) {
+		slplink->dc = NULL;
+		if (slplink->swboard == NULL)
+			msn_slplink_destroy(slplink);
+	}
 
 	g_free(dc->msg_body);
 
--- a/libpurple/protocols/msn/slplink.c	Sun May 23 17:26:20 2010 +0000
+++ b/libpurple/protocols/msn/slplink.c	Sun May 23 21:45:19 2010 +0000
@@ -101,8 +101,11 @@
 
 	session = slplink->session;
 
-	if (slplink->dc != NULL)
+	if (slplink->dc != NULL) {
+		slplink->dc->slplink = NULL;
 		msn_dc_destroy(slplink->dc);
+		slplink->dc = NULL;
+	}
 
 	while (slplink->slp_calls != NULL)
 		msn_slpcall_destroy(slplink->slp_calls->data);
@@ -203,12 +206,16 @@
 	/* The slplink has no slpcalls in it, release it from MSN_SB_FLAG_FT.
 	 * If nothing else is using it then this might cause swboard to be
 	 * destroyed. */
-	if (slplink->slp_calls == NULL && slplink->swboard != NULL)
+	if (slplink->slp_calls == NULL && slplink->swboard != NULL) {
 		msn_switchboard_release(slplink->swboard, MSN_SB_FLAG_FT);
+		slplink->swboard = NULL;
+	}
 
 	/* The slplink has no slpcalls in it, release it from the DC. */
-	if (slplink->slp_calls == NULL && slplink->dc != NULL)
+	if (slplink->slp_calls == NULL && slplink->dc != NULL) {
 		msn_dc_destroy(slplink->dc);
+		slplink->dc = NULL;
+	}
 }
 
 MsnSlpCall *