changeset 28660:578b4048a501

More tightly scope a variable and avoid trying to free an unset variable. Patch from Brian Lu. Closes #10242. committer: Paul Aurich <paul@darkrain42.org>
author brian.lu@sun.com
date Fri, 25 Sep 2009 03:39:35 +0000
parents c42d5c23a9e8
children a143b7fcff4c
files COPYRIGHT ChangeLog libpurple/dnsquery.c
diffstat 3 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/COPYRIGHT	Thu Sep 24 16:58:31 2009 +0000
+++ b/COPYRIGHT	Fri Sep 25 03:39:35 2009 +0000
@@ -275,6 +275,7 @@
 Lokheed
 Norberto Lopes
 Shlomi Loubaton
+Brian Lu
 Uli Luckas
 Matthew Luckie
 Marcus Lundblad
--- a/ChangeLog	Thu Sep 24 16:58:31 2009 +0000
+++ b/ChangeLog	Fri Sep 25 03:39:35 2009 +0000
@@ -10,6 +10,8 @@
 	General:
 	* New 'plugins' sub-command to 'debug' command (i.e. '/debug plugins')
 	  to announce the list of loaded plugins (in both Finch and Pidgin).
+	* Fix a crash when performing DNS queries on Unixes that use the
+	  blocking DNS lookups.  (Brian Lu)
 
 version 2.6.2 (09/05/2009):
 	libpurple:
--- a/libpurple/dnsquery.c	Thu Sep 24 16:58:31 2009 +0000
+++ b/libpurple/dnsquery.c	Fri Sep 25 03:39:35 2009 +0000
@@ -918,7 +918,6 @@
 	PurpleDnsQueryData *query_data;
 	struct sockaddr_in sin;
 	GSList *hosts = NULL;
-	char *hostname;
 
 	query_data = data;
 	query_data->timeout = 0;
@@ -931,6 +930,7 @@
 
 	if (!inet_aton(query_data->hostname, &sin.sin_addr)) {
 		struct hostent *hp;
+		gchar *hostname;
 #ifdef USE_IDN
 		if (!dns_str_is_ascii(query_data->hostname)) {
 			int ret = purple_network_convert_idn_to_ascii(query_data->hostname,
@@ -956,11 +956,11 @@
 		memset(&sin, 0, sizeof(struct sockaddr_in));
 		memcpy(&sin.sin_addr.s_addr, hp->h_addr, hp->h_length);
 		sin.sin_family = hp->h_addrtype;
+		g_free(hostname);
 	} else
 		sin.sin_family = AF_INET;
 	sin.sin_port = htons(query_data->port);
 
-	g_free(hostname);
 	hosts = g_slist_append(hosts, GINT_TO_POINTER(sizeof(sin)));
 	hosts = g_slist_append(hosts, g_memdup(&sin, sizeof(sin)));