pidgin: 2344ffb8: Lots of little memleak fixes

markdoliner at pidgin.im markdoliner at pidgin.im
Mon Apr 12 04:02:49 EDT 2010


-----------------------------------------------------------------
Revision: 2344ffb8efb6f72280ac4e25a597b651d8927d6f
Ancestor: 568fccc374c5310aa13839469fb3ca6339b94346
Author: markdoliner at pidgin.im
Date: 2010-04-12T07:58:08
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/2344ffb8efb6f72280ac4e25a597b651d8927d6f

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

ChangeLog: 

Lots of little memleak fixes

-------------- next part --------------
============================================================
--- libpurple/protocols/simple/simple.c	82905826ce43350183a7f6be10aa5fad1de18835
+++ libpurple/protocols/simple/simple.c	a8bd17233112abb7ef5d26f84f7554fe51174a10
@@ -1653,6 +1653,7 @@ static void process_input(struct simple_
 		}
 		purple_debug(PURPLE_DEBUG_MISC, "simple", "in process response response: %d\n", msg->response);
 		process_input_message(sip, msg);
+		sipmsg_free(msg);
 	} else {
 		purple_debug(PURPLE_DEBUG_MISC, "simple", "received a incomplete sip msg: %s\n", conn->inbuf);
 	}
@@ -1671,6 +1672,7 @@ static void simple_udp_process(gpointer 
 		purple_debug_info("simple", "\n\nreceived - %s\n######\n%s\n#######\n\n", ctime(&currtime), buffer);
 		msg = sipmsg_parse_msg(buffer);
 		if(msg) process_input_message(sip, msg);
+		sipmsg_free(msg);
 	}
 }
 
@@ -2021,6 +2023,9 @@ static void simple_close(PurpleConnectio
 	g_free(sip->proxy.target);
 	g_free(sip->proxy.realm);
 	g_free(sip->proxy.digest_session_key);
+	g_free(sip->status);
+	g_hash_table_destroy(sip->buddies);
+	g_free(sip->regcallid);
 	g_free(sip->publish_etag);
 	if (sip->txbuf)
 		purple_circ_buffer_destroy(sip->txbuf);
============================================================
--- libpurple/protocols/simple/sipmsg.c	569626e5550996b92bb9b1ef1105d6b0c01a4ade
+++ libpurple/protocols/simple/sipmsg.c	7cc8ed9e084cdb09a8f293e00017eab5d4d5b604
@@ -55,15 +55,15 @@ struct sipmsg *sipmsg_parse_header(const
 }
 
 struct sipmsg *sipmsg_parse_header(const gchar *header) {
-	struct sipmsg *msg = g_new0(struct sipmsg,1);
-	gchar **parts, **lines = g_strsplit(header,"\r\n",0);
+	struct sipmsg *msg;
+	gchar **parts, **lines;
 	gchar *dummy, *dummy2, *tmp;
 	const gchar *tmp2;
 	int i = 1;
 
+	lines = g_strsplit(header,"\r\n",0);
 	if(!lines[0]) {
 		g_strfreev(lines);
-		g_free(msg);
 		return NULL;
 	}
 
@@ -71,10 +71,10 @@ struct sipmsg *sipmsg_parse_header(const
 	if(!parts[0] || !parts[1] || !parts[2]) {
 		g_strfreev(parts);
 		g_strfreev(lines);
-		g_free(msg);
 		return NULL;
 	}
 
+	msg = g_new0(struct sipmsg,1);
 	if(strstr(parts[0],"SIP")) { /* numeric response */
 		msg->method = g_strdup(parts[2]);
 		msg->response = strtol(parts[1],NULL,10);
@@ -90,7 +90,7 @@ struct sipmsg *sipmsg_parse_header(const
 		if(!parts[0] || !parts[1]) {
 			g_strfreev(parts);
 			g_strfreev(lines);
-			g_free(msg);
+			sipmsg_free(msg);
 			return NULL;
 		}
 		dummy = parts[1];
@@ -106,6 +106,7 @@ struct sipmsg *sipmsg_parse_header(const
 			dummy2 = tmp;
 		}
 		sipmsg_add_header(msg, parts[0], dummy2);
+		g_free(dummy2);
 		g_strfreev(parts);
 	}
 	g_strfreev(lines);
@@ -116,9 +117,10 @@ struct sipmsg *sipmsg_parse_header(const
 
 	if(msg->response) {
 		tmp2 = sipmsg_find_header(msg, "CSeq");
+		g_free(msg->method);
 		if(!tmp2) {
 			/* SHOULD NOT HAPPEN */
-			msg->method = 0;
+			msg->method = NULL;
 		} else {
 			parts = g_strsplit(tmp2, " ", 2);
 			msg->method = g_strdup(parts[1]);
@@ -168,7 +170,7 @@ void sipmsg_add_header(struct sipmsg *ms
 	return g_string_free(outstr, FALSE);
 }
 void sipmsg_add_header(struct sipmsg *msg, const gchar *name, const gchar *value) {
-	struct siphdrelement *element = g_new0(struct siphdrelement,1);
+	struct siphdrelement *element = g_new(struct siphdrelement,1);
 	element->name = g_strdup(name);
 	element->value = g_strdup(value);
 	msg->headers = g_slist_append(msg->headers, element);


More information about the Commits mailing list