diff src/protocols/simple/sipmsg.c @ 11439:617e67e1c985

[gaim-migrate @ 13676] Fixed a couple leaks and potential leaks. The retval of g_strsplit() needs to be g_strfreev()'d. Also some "declaration after code" fixes. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Sun, 04 Sep 2005 18:05:48 +0000
parents 90290f579926
children 0d18fa6c3b41
line wrap: on
line diff
--- a/src/protocols/simple/sipmsg.c	Sun Sep 04 07:14:04 2005 +0000
+++ b/src/protocols/simple/sipmsg.c	Sun Sep 04 18:05:48 2005 +0000
@@ -56,6 +56,8 @@
 	int i=1;
 	parts = g_strsplit(lines[0], " ", 3);
 	if(!parts[0] || !parts[1] || !parts[2]) {
+		g_strfreev(parts);
+		g_strfreev(lines);
 		g_free(msg);
 		return NULL;
 	}
@@ -71,6 +73,8 @@
 	for(i=1; lines[i] && strlen(lines[i])>2; i++) {
 		parts = g_strsplit(lines[i], ":", 2);
 		if(!parts[0] || !parts[1]) {
+			g_strfreev(parts);
+			g_strfreev(lines);
 			g_free(msg);
 			return NULL;
 		}
@@ -89,6 +93,7 @@
 		sipmsg_add_header(msg, parts[0], dummy2);
 		g_strfreev(parts);
 	}
+	g_strfreev(lines);
 	msg->bodylen = strtol(sipmsg_find_header(msg, "Content-Length"),NULL,10);
 	if(msg->response) {
 		tmp = sipmsg_find_header(msg, "CSeq");
@@ -113,11 +118,11 @@
 	cur = msg->headers;
 	while(cur) {
 		elem = cur->data;
-	        gaim_debug(GAIM_DEBUG_MISC, "simple", "name: %s value: %s\n",elem->name, elem->value);
+		gaim_debug(GAIM_DEBUG_MISC, "simple", "name: %s value: %s\n",elem->name, elem->value);
 		cur = g_slist_next(cur);
 	}
 }
-	
+
 char *sipmsg_to_string(struct sipmsg *msg) {
 	gchar *out;
 	gchar *old;
@@ -129,7 +134,7 @@
 	while(cur) {
 		elem = cur->data;
 		old = out;
-	        out = g_strdup_printf("%s%s: %s\r\n", out, elem->name, elem->value);
+		out = g_strdup_printf("%s%s: %s\r\n", out, elem->name, elem->value);
 		g_free(old);
 		cur = g_slist_next(cur);
 	}
@@ -150,7 +155,7 @@
 	element->value = g_strdup(value);
 	msg->headers = g_slist_append(msg->headers, element);
 }
-			
+
 void sipmsg_free(struct sipmsg *msg) {
 	struct siphdrelement *elem;
 	while(msg->headers) {