changeset 20489:321d25932f5e

Fix a bug where we were g_strdup'ing a previously freed pointer. Thanks to khc for the debugging.
author Carlos Silva <typ0@pidgin.im>
date Mon, 03 Sep 2007 20:32:57 +0000
parents 64c322c3b1b0
children 2d8999540239
files libpurple/protocols/msn/contact.c libpurple/protocols/msn/soap.c
diffstat 2 files changed, 33 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/contact.c	Mon Sep 03 06:15:55 2007 +0000
+++ b/libpurple/protocols/msn/contact.c	Mon Sep 03 20:32:57 2007 +0000
@@ -97,45 +97,65 @@
 void
 msn_callback_state_set_who(MsnCallbackState *state, const gchar *who)
 {
+	gchar *new_str = NULL;
+
 	g_return_if_fail(state != NULL);
+
+	if (who != NULL)
+		new_str = g_strdup(who);
 	
 	if (state->who != NULL)
 		g_free(state->who);
 	
-	state->who = who != NULL ? g_strdup(who) : NULL;
+	state->who = new_str;
 }
 
 void
 msn_callback_state_set_old_group_name(MsnCallbackState *state, const gchar *old_group_name)
 {
+	gchar *new_str = NULL;
+
 	g_return_if_fail(state != NULL);
-	
+
+	if (old_group_name != NULL)
+		new_str = g_strdup(old_group_name);
+
 	if (state->old_group_name != NULL)
 		g_free(state->old_group_name);
 	
-	state->old_group_name = old_group_name != NULL ? g_strdup(old_group_name) : NULL;
+	state->old_group_name = new_str;
 }
 
 void
 msn_callback_state_set_new_group_name(MsnCallbackState *state, const gchar *new_group_name)
 {
+	gchar *new_str = NULL;
+
 	g_return_if_fail(state != NULL);
-	
+
+	if (new_group_name != NULL)
+		new_str = g_strdup(new_group_name);
+
 	if (state->new_group_name != NULL)
 		g_free(state->new_group_name);
 	
-	state->new_group_name = new_group_name != NULL ? g_strdup(new_group_name) : NULL;
+	state->new_group_name = new_str;
 }
 
 void
 msn_callback_state_set_guid(MsnCallbackState *state, const gchar *guid)
 {
+	gchar *new_str = NULL;
+
 	g_return_if_fail(state != NULL);
+
+	if (guid != NULL)
+		new_str = g_strdup(guid);
 	
 	if (state->guid != NULL)
 		g_free(state->guid);
 	
-	state->guid = guid != NULL ? g_strdup(guid) : NULL;
+	state->guid = new_str;
 }
 
 
--- a/libpurple/protocols/msn/soap.c	Mon Sep 03 06:15:55 2007 +0000
+++ b/libpurple/protocols/msn/soap.c	Mon Sep 03 20:32:57 2007 +0000
@@ -634,6 +634,8 @@
 void
 msn_soap_post_head_request(MsnSoapConn *soapconn)
 {
+	purple_debug_info("MSN SOAP", "Posting new request from head of the queue\n");
+	
 	g_return_if_fail(soapconn->soap_queue != NULL);
 
 	if(!g_queue_is_empty(soapconn->soap_queue)){
@@ -641,8 +643,10 @@
 		if((request = g_queue_pop_head(soapconn->soap_queue)) != NULL){
 			msn_soap_post_request(soapconn,request);
 		}
+	} else {
+		purple_debug_info("MSN SOAP", "No requests to process found.\n");
+		msn_soap_set_process_step(soapconn,MSN_SOAP_CONNECTED_IDLE);
 	}
-	msn_soap_set_process_step(soapconn,MSN_SOAP_CONNECTED_IDLE);
 }
 
 /*post the soap request ,
@@ -670,11 +674,9 @@
 	 * we just waiting...
 	 * If we send the request this time,error may occure
 	 */
-#if 0
-	if(soapconn->step == MSN_SOAP_CONNECTED_IDLE){
+	if (soapconn->step == MSN_SOAP_CONNECTED_IDLE){
 		msn_soap_post_head_request(soapconn);
 	}
-#endif
 }
 
 /*Post the soap request action*/
@@ -690,7 +692,7 @@
 	purple_debug_misc("MSN SOAP","msn_soap_post_request()\n");
 #endif
 
-	msn_soap_set_process_step(soapconn,MSN_SOAP_PROCESSING);
+	msn_soap_set_process_step(soapconn, MSN_SOAP_PROCESSING);
 	soap_head = g_strdup_printf(
 					"POST %s HTTP/1.1\r\n"
 					"SOAPAction: %s\r\n"