pidgin: eb27c61e: Fix a potential leak, thanks to "KuSh". ...

datallah at pidgin.im datallah at pidgin.im
Thu Nov 6 22:00:40 EST 2008


-----------------------------------------------------------------
Revision: eb27c61e427e040d34c8af1ff2ab1e5b85c91807
Ancestor: a32006b99c498657c8e6578cdb526265064d7e98
Author: datallah at pidgin.im
Date: 2008-11-07T02:49:23
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/eb27c61e427e040d34c8af1ff2ab1e5b85c91807

Modified files:
        libpurple/protocols/simple/sipmsg.c

ChangeLog: 

Fix a potential leak, thanks to "KuSh".  Fixes #7465.

-------------- next part --------------
============================================================
--- libpurple/protocols/simple/sipmsg.c	b35e6387902fa90429664edb9b52a1dbfdbae098
+++ libpurple/protocols/simple/sipmsg.c	569626e5550996b92bb9b1ef1105d6b0c01a4ade
@@ -56,14 +56,17 @@ struct sipmsg *sipmsg_parse_header(const
 
 struct sipmsg *sipmsg_parse_header(const gchar *header) {
 	struct sipmsg *msg = g_new0(struct sipmsg,1);
-	gchar **lines = g_strsplit(header,"\r\n",0);
-	gchar **parts;
-	gchar *dummy;
-	gchar *dummy2;
-	gchar *tmp;
+	gchar **parts, **lines = g_strsplit(header,"\r\n",0);
+	gchar *dummy, *dummy2, *tmp;
 	const gchar *tmp2;
-	int i=1;
-	if(!lines[0]) return NULL;
+	int i = 1;
+
+	if(!lines[0]) {
+		g_strfreev(lines);
+		g_free(msg);
+		return NULL;
+	}
+
 	parts = g_strsplit(lines[0], " ", 3);
 	if(!parts[0] || !parts[1] || !parts[2]) {
 		g_strfreev(parts);
@@ -71,6 +74,7 @@ struct sipmsg *sipmsg_parse_header(const
 		g_free(msg);
 		return NULL;
 	}
+
 	if(strstr(parts[0],"SIP")) { /* numeric response */
 		msg->method = g_strdup(parts[2]);
 		msg->response = strtol(parts[1],NULL,10);
@@ -80,6 +84,7 @@ struct sipmsg *sipmsg_parse_header(const
 		msg->response = 0;
 	}
 	g_strfreev(parts);
+
 	for(i=1; lines[i] && strlen(lines[i])>2; i++) {
 		parts = g_strsplit(lines[i], ":", 2);
 		if(!parts[0] || !parts[1]) {
@@ -104,9 +109,11 @@ struct sipmsg *sipmsg_parse_header(const
 		g_strfreev(parts);
 	}
 	g_strfreev(lines);
+
 	tmp2 = sipmsg_find_header(msg, "Content-Length");
 	if (tmp2 != NULL)
 		msg->bodylen = strtol(tmp2, NULL, 10);
+
 	if(msg->response) {
 		tmp2 = sipmsg_find_header(msg, "CSeq");
 		if(!tmp2) {
@@ -118,6 +125,7 @@ struct sipmsg *sipmsg_parse_header(const
 			g_strfreev(parts);
 		}
 	}
+
 	return msg;
 }
 


More information about the Commits mailing list