changeset 26551:5d1140b0b10a

Don't leak the struct sockaddr* from purple_dnsquery_a. At least one of these gives me: ==00:00:06:28.468 13659== 32 bytes in 2 blocks are definitely lost in loss record 1,020 of 3,383 ==00:00:06:28.468 13659== at 0x04c278ae: malloc (vg_replace_malloc.c:207) ==00:00:06:28.468 13659== by 0x09b29a12: g_malloc (gmem.c:131) ==00:00:06:28.468 13659== by 0x07d2fd8c: host_resolved (dnsquery.c:578)
author Paul Aurich <paul@darkrain42.org>
date Sun, 12 Apr 2009 22:23:34 +0000
parents 7f9443c31101
children 4bac03b3c0fd
files libpurple/network.c libpurple/protocols/jabber/google.c libpurple/stun.c
diffstat 3 files changed, 19 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/network.c	Sun Apr 12 21:53:41 2009 +0000
+++ b/libpurple/network.c	Sun Apr 12 22:23:34 2009 +0000
@@ -825,8 +825,13 @@
 		*ip = g_strdup(dst);
 		purple_debug_info("network", "set IP address: %s\n", *ip);
 	}
-	
-	g_slist_free(hosts);
+
+	while (hosts != NULL) {
+		hosts = g_slist_delete_link(hosts, hosts);
+		/* Free the address */
+		g_free(hosts->data);
+		hosts = g_slist_delete_link(hosts, hosts);
+	}
 }
 
 void
--- a/libpurple/protocols/jabber/google.c	Sun Apr 12 21:53:41 2009 +0000
+++ b/libpurple/protocols/jabber/google.c	Sun Apr 12 22:23:34 2009 +0000
@@ -1156,7 +1156,12 @@
 		}
 	}
 
-	g_slist_free(hosts);
+	while (hosts != NULL) {
+		hosts = g_slist_delete_link(hosts, hosts);
+		/* Free the address */
+		g_free(hosts->data);
+		hosts = g_slist_delete_link(hosts, hosts);
+	}
 }
 
 static void
--- a/libpurple/stun.c	Sun Apr 12 21:53:41 2009 +0000
+++ b/libpurple/stun.c	Sun Apr 12 22:23:34 2009 +0000
@@ -341,6 +341,12 @@
 	}
 
 	if (!purple_network_listen_range(12108, 12208, SOCK_DGRAM, hbn_listen_cb, hosts)) {
+		while(hosts) {
+			hosts = g_slist_remove(hosts, hosts->data);
+			g_free(hosts->data);
+			hosts = g_slist_remove(hosts, hosts->data);
+		}
+
 		nattype.status = PURPLE_STUN_STATUS_UNKNOWN;
 		nattype.lookup_time = time(NULL);
 		do_callbacks();