pidgin: e4038d4f: Fix a crash when the account is disconne...

masca at cpw.pidgin.im masca at cpw.pidgin.im
Sun Aug 14 15:10:46 EDT 2011


----------------------------------------------------------------------
Revision: e4038d4f52e6856643df0bce1488a565385a851f
Parent:   4155786dc74833813772e14bdffe59b2464cda13
Author:   masca at cpw.pidgin.im
Date:     08/14/11 15:04:59
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/e4038d4f52e6856643df0bce1488a565385a851f

Changelog: 

Fix a crash when the account is disconnected and we have requested a SB. (Hanzz, ported by shlomif)(Fixes #12431)


Changes against parent 4155786dc74833813772e14bdffe59b2464cda13

  patched  ChangeLog
  patched  libpurple/protocols/msn/cmdproc.c
  patched  libpurple/protocols/msn/cmdproc.h
  patched  libpurple/protocols/msn/session.c
  patched  libpurple/protocols/msn/switchboard.c
  patched  libpurple/protocols/msn/switchboard.h

-------------- next part --------------
============================================================
--- ChangeLog	1601f24796178a3802e8f67481df198eb03c6c7d
+++ ChangeLog	d773049728269b0d8dcf44fc117c3a9d424fd24c
@@ -37,6 +37,8 @@ version 2.10.0 (MM/DD/YYYY):
 
 	MSN:
 	* Fix seemingly random crashing. (#14307)
+	* Fix a crash when the account is disconnected at the time we are doing a
+	  SB request. (Hanzz, ported by shlomif) (#12431)
 
 	XMPP:
 	* Do not generate malformed XML ("</>") when setting an empty mood.
============================================================
--- libpurple/protocols/msn/switchboard.c	e9d36aa19e7e337d760d7b64d3f3f06c0304f284
+++ libpurple/protocols/msn/switchboard.c	df8530257f896961eb86df5eb80653d92e7d1cd8
@@ -421,9 +421,10 @@ msg_resend_cb(gpointer data)
 
 	purple_debug_info("msn", "unqueuing unsent message to %s\n", swboard->im_user);
 
-	msn_switchboard_request(swboard);
-	msn_switchboard_request_add_user(swboard, swboard->im_user);
-	swboard->reconn_timeout_h = 0;
+	if (msn_switchboard_request(swboard)) {
+		msn_switchboard_request_add_user(swboard, swboard->im_user);
+		swboard->reconn_timeout_h = 0;
+	}
 	return FALSE;
 }
 
@@ -1078,7 +1079,7 @@ xfr_error(MsnCmdProc *cmdproc, MsnTransa
 	swboard_error_helper(swboard, reason, swboard->im_user);
 }
 
-void
+gboolean
 msn_switchboard_request(MsnSwitchBoard *swboard)
 {
 	MsnCmdProc *cmdproc;
@@ -1094,7 +1095,7 @@ msn_switchboard_request(MsnSwitchBoard *
 	msn_transaction_set_data(trans, swboard);
 	msn_transaction_set_error_cb(trans, xfr_error);
 
-	msn_cmdproc_send_trans(cmdproc, trans);
+	return msn_cmdproc_send_trans(cmdproc, trans);
 }
 
 void
============================================================
--- libpurple/protocols/msn/switchboard.h	56cc2f378d15a8414f63d988e5345c89330ee9f2
+++ libpurple/protocols/msn/switchboard.h	180663d5b3c8da39dcd9b22459df2828b49e0013
@@ -250,7 +250,7 @@ gboolean msn_switchboard_chat_invite(Msn
 gboolean msn_switchboard_chat_leave(MsnSwitchBoard *swboard);
 gboolean msn_switchboard_chat_invite(MsnSwitchBoard *swboard, const char *who);
 
-void msn_switchboard_request(MsnSwitchBoard *swboard);
+gboolean msn_switchboard_request(MsnSwitchBoard *swboard);
 void msn_switchboard_request_add_user(MsnSwitchBoard *swboard, const char *user);
 
 /**
============================================================
--- libpurple/protocols/msn/session.c	2315ac5ba17d64b18436b6a5efa05a0a4485c10a
+++ libpurple/protocols/msn/session.c	e026000c2dd603d8e5e15eafdb5210751fce66c2
@@ -263,8 +263,10 @@ msn_session_get_swboard(MsnSession *sess
 	{
 		swboard = msn_switchboard_new(session);
 		swboard->im_user = g_strdup(username);
-		msn_switchboard_request(swboard);
-		msn_switchboard_request_add_user(swboard, username);
+		if (msn_switchboard_request(swboard))
+			msn_switchboard_request_add_user(swboard, username);
+		else
+			return NULL;
 	}
 
 	swboard->flag |= flag;
============================================================
--- libpurple/protocols/msn/cmdproc.c	45f779a56031d8b4aec7ee5a743be61540d91335
+++ libpurple/protocols/msn/cmdproc.c	ef261769dfd2998cf9c097b2b05cd5e43cf42083
@@ -109,21 +109,22 @@ show_debug_cmd(MsnCmdProc *cmdproc, gboo
 	g_free(show);
 }
 
-void
+gboolean
 msn_cmdproc_send_trans(MsnCmdProc *cmdproc, MsnTransaction *trans)
 {
 	MsnServConn *servconn;
 	char *data;
 	size_t len;
+	gboolean ret;
 
-	g_return_if_fail(cmdproc != NULL);
-	g_return_if_fail(trans != NULL);
+	g_return_val_if_fail(cmdproc != NULL, TRUE);
+	g_return_val_if_fail(trans != NULL, TRUE);
 
 	servconn = cmdproc->servconn;
 
 	if (!servconn->connected) {
 		msn_transaction_destroy(trans);
-		return;
+		return FALSE;
 	}
 
 	if (trans->saveable)
@@ -154,11 +155,12 @@ msn_cmdproc_send_trans(MsnCmdProc *cmdpr
 		trans->payload_len = 0;
 	}
 
-	msn_servconn_write(servconn, data, len);
+	ret = msn_servconn_write(servconn, data, len) != -1;
 
 	if (!trans->saveable)
 		msn_transaction_destroy(trans);
 	g_free(data);
+	return ret;
 }
 
 void
============================================================
--- libpurple/protocols/msn/cmdproc.h	08b0de92f4984011d756025b23c44ad84beed946
+++ libpurple/protocols/msn/cmdproc.h	85a54bbcb9e92bd0c1722be352ba4bdff0509a09
@@ -79,7 +79,7 @@ void msn_cmdproc_process_queue(MsnCmdPro
  * @param cmdproc 	The MsnCmdProc to be used.
  * @param trans 	The MsnTransaction to be sent.
  */
-void msn_cmdproc_send_trans(MsnCmdProc *cmdproc, MsnTransaction *trans);
+gboolean msn_cmdproc_send_trans(MsnCmdProc *cmdproc, MsnTransaction *trans);
 
 /**
  * Add a transaction to the queue to be processed latter.


More information about the Commits mailing list