changeset 20935:1d9d5de48b9e

Fix some leaks.
author Daniel Atallah <daniel.atallah@gmail.com>
date Mon, 15 Oct 2007 00:31:34 +0000
parents 6739d93f95c1
children 1d8969748cd9 65d19253f746
files libpurple/protocols/msn/httpconn.c libpurple/protocols/msn/msg.c libpurple/protocols/msn/notification.c
diffstat 3 files changed, 18 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/httpconn.c	Sun Oct 14 23:26:52 2007 +0000
+++ b/libpurple/protocols/msn/httpconn.c	Mon Oct 15 00:31:34 2007 +0000
@@ -169,7 +169,7 @@
 	/* Now we should be able to process the data. */
 	if ((s = purple_strcasestr(header, "X-MSN-Messenger: ")) != NULL)
 	{
-		char *full_session_id, *gw_ip, *session_action;
+		gchar *full_session_id = NULL, *gw_ip = NULL, *session_action = NULL;
 		char *t, *session_id;
 		char **elems, **cur, **tokens;
 
@@ -196,13 +196,16 @@
 		{
 			tokens = g_strsplit(*cur, "=", 2);
 
-			if (strcmp(tokens[0], "SessionID") == 0)
+			if (strcmp(tokens[0], "SessionID") == 0) {
+				g_free(full_session_id);
 				full_session_id = tokens[1];
-			else if (strcmp(tokens[0], "GW-IP") == 0)
+			} else if (strcmp(tokens[0], "GW-IP") == 0) {
+				g_free(gw_ip);
 				gw_ip = tokens[1];
-			else if (strcmp(tokens[0], "Session") == 0)
+			} else if (strcmp(tokens[0], "Session") == 0) {
+				g_free(session_action);
 				session_action = tokens[1];
-			else
+			} else
 				g_free(tokens[1]);
 
 			g_free(tokens[0]);
--- a/libpurple/protocols/msn/msg.c	Sun Oct 14 23:26:52 2007 +0000
+++ b/libpurple/protocols/msn/msg.c	Mon Oct 15 00:31:34 2007 +0000
@@ -664,10 +664,11 @@
 
 		tokens = g_strsplit(*cur, ": ", 2);
 
-		if (tokens[0] != NULL && tokens[1] != NULL)
+		if (tokens[0] != NULL && tokens[1] != NULL) {
 			g_hash_table_insert(table, tokens[0], tokens[1]);
-
-		g_free(tokens);
+			g_free(tokens);
+		} else
+			g_strfreev(tokens);
 	}
 
 	g_strfreev(elems);
--- a/libpurple/protocols/msn/notification.c	Sun Oct 14 23:26:52 2007 +0000
+++ b/libpurple/protocols/msn/notification.c	Mon Oct 15 00:31:34 2007 +0000
@@ -262,14 +262,15 @@
 		for (cur = elems; *cur != NULL; cur++)
 		{
 			tokens = g_strsplit(*cur, "=", 2);
-			if(tokens[0]&&tokens[1])
+			if(tokens[0] && tokens[1])
 			{
 				purple_debug_info("MSNP14","challenge %p,key:%s,value:%s\n",
 									session->nexus->challenge_data,tokens[0],tokens[1]);
 				g_hash_table_insert(session->nexus->challenge_data, tokens[0], tokens[1]);
-			}
-			/* Don't free each of the tokens, only the array. */
-			g_free(tokens);
+				/* Don't free each of the tokens, only the array. */
+				g_free(tokens);
+			} else
+				g_strfreev(tokens);
 		}
 
 		g_strfreev(elems);
@@ -735,7 +736,7 @@
 	msn_cmdproc_send_trans(cmdproc, trans);
 
 	g_free(payload);
-	g_free(tokens);
+	g_strfreev(tokens);
 }
 
 static void