changeset 23495:b82a17934604

fixed a memleak or 3, or maybe 4, or 5. Some of these applies to the p14 code as well
author Ka-Hing Cheung <khc@hxbc.us>
date Wed, 26 Dec 2007 02:30:07 +0000
parents 8315e4604226
children aa25bb450139
files libpurple/protocols/msn/msn.c libpurple/protocols/msn/nexus.c libpurple/protocols/msn/oim.c libpurple/protocols/msn/session.c libpurple/protocols/msn/soap2.c
diffstat 5 files changed, 25 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/msn.c	Wed Dec 26 02:27:18 2007 +0000
+++ b/libpurple/protocols/msn/msn.c	Wed Dec 26 02:30:07 2007 +0000
@@ -927,7 +927,10 @@
 	}
 
 	msn_import_html(message, &msgformat, &msgtext);
-	if(msn_user_is_online(account, who)||
+	/* this is incorrect, we should try to initiate a connection to the
+	   buddy first, and only falls back if that fails. Otherwise we can
+	   only send offline message to invisible buddies */
+	if (msn_user_is_online(account, who)||
 		msn_user_is_yahoo(account, who)){
 		/*User online,then send Online Instant Message*/
 
@@ -994,7 +997,7 @@
 		}
 
 		msn_message_destroy(msg);
-	}else	{
+	} else {
 		/*send Offline Instant Message,only to MSN Passport User*/
 		MsnSession *session;
 		char *friendname;
@@ -1005,8 +1008,11 @@
 		friendname = msn_encode_mime(account->username);
 		msn_oim_prep_send_msg_info(session->oim,
 			purple_account_get_username(account),
-			friendname, who,	message);
+			friendname, who, msgformat);
 		msn_oim_send_msg(session->oim);
+
+		g_free(msgformat);
+		g_free(msgtext);
 		g_free(friendname);
 	}
 
--- a/libpurple/protocols/msn/nexus.c	Wed Dec 26 02:27:18 2007 +0000
+++ b/libpurple/protocols/msn/nexus.c	Wed Dec 26 02:30:07 2007 +0000
@@ -246,18 +246,19 @@
 		xmlnode *expires = msn_soap_xml_get(node, "LifeTime/Expires");
 
 		if (token) {
-			char *token_str = xmlnode_get_data(token);
+			char *token_str, *expiry_str;
 			const char *id_str = xmlnode_get_attrib(token, "Id");
 			char **elems, **cur, **tokens;
 			int id;
 
-			if (token_str == NULL) continue;
 			if (id_str == NULL) continue;
 
 			id = atol(id_str + 7) - 1;	/* 'Compact#' or 'PPToken#' */
 			if (id >= nexus->token_len)
 				continue;	/* Where did this come from? */
 
+			token_str = xmlnode_get_data(token);
+			if (token_str == NULL) continue;
 			elems = g_strsplit(token_str, "&", 0);
 
 			for (cur = elems; *cur != NULL; cur++){
@@ -271,13 +272,17 @@
 			g_strfreev(elems);
 
 			if (secret)
-				nexus->tokens[id].secret = g_strdup(xmlnode_get_data(secret));
+				nexus->tokens[id].secret = xmlnode_get_data(secret);
 			else
 				nexus->tokens[id].secret = NULL;
 
 			/* Yay for MS using ISO-8601 */
-			nexus->tokens[id].expiry = purple_str_to_time(xmlnode_get_data(expires),
-			                                              FALSE, NULL, NULL, NULL);
+			expiry_str = xmlnode_get_data(expires);
+
+			nexus->tokens[id].expiry = purple_str_to_time(expiry_str,
+				FALSE, NULL, NULL, NULL);
+
+			g_free(expiry_str);
 
 			purple_debug_info("msnp15", "Updated ticket for domain '%s'\n",
 			                  ticket_domains[id][SSO_VALID_TICKET_DOMAIN]);
--- a/libpurple/protocols/msn/oim.c	Wed Dec 26 02:27:18 2007 +0000
+++ b/libpurple/protocols/msn/oim.c	Wed Dec 26 02:30:07 2007 +0000
@@ -161,6 +161,8 @@
 					xmlnode *challengeNode = msn_soap_xml_get(faultNode,
 						"detail/LockKeyChallenge");
 
+					g_free(faultcode_str);
+
 					if (challengeNode == NULL) {
 						if (oim->challenge) {
 							g_free(oim->challenge);
--- a/libpurple/protocols/msn/session.c	Wed Dec 26 02:27:18 2007 +0000
+++ b/libpurple/protocols/msn/session.c	Wed Dec 26 02:30:07 2007 +0000
@@ -100,7 +100,7 @@
 	if (session->user != NULL)
 		msn_user_destroy(session->user);
 
-	if (session->soap_table)
+	if (session->soap_table != NULL)
 		g_hash_table_destroy(session->soap_table);
 
 	if (session->soap_cleanup_handle)
--- a/libpurple/protocols/msn/soap2.c	Wed Dec 26 02:27:18 2007 +0000
+++ b/libpurple/protocols/msn/soap2.c	Wed Dec 26 02:30:07 2007 +0000
@@ -229,6 +229,7 @@
 				}
 
 				g_free(faultdata);
+				msn_soap_message_destroy(response);
 				return TRUE;
 			} else if (g_str_equal(faultdata, "wsse:FailedAuthentication")) {
 				xmlnode *reason = xmlnode_get_child(body, "faultstring");
@@ -240,6 +241,7 @@
 
 				g_free(reasondata);
 				g_free(faultdata);
+				msn_soap_message_destroy(response);
 				return FALSE;
 			}
 
@@ -252,6 +254,7 @@
 		conn->current_request = NULL;
 		request->cb(request->message, response,
 			request->cb_data);
+		msn_soap_message_destroy(response);
 		msn_soap_request_destroy(request);
 	}