changeset 24469:002a58d4af7d

Fix a crash Jacky Lam noted on devel@pidgin.im: Currently, I experience crash at dnsquery.c:purple_dnsquery_destroy() when my WiFi AP suddenly off while I am online with libpurple. After tracing, I find the data struct PurpleDnsQueryData is freeing twice. The reason is when purple_dnsquery_failed() is called, purple_dnsquery_destroy() will try to free the PurpleDnsQueryData's resolver and itself. But purple_dnsquery_resolver_destroy()'s kill() will trigger the glib's input hook and finally called host_resolved() and eventually call purple_dnsquery_failed() again!!
author Richard Laager <rlaager@wiktel.com>
date Mon, 17 Nov 2008 19:30:27 +0000
parents e5efa83aa6d2
children d038fc351194 798413cd4c17
files COPYRIGHT libpurple/dnsquery.c
diffstat 2 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/COPYRIGHT	Mon Nov 17 19:28:39 2008 +0000
+++ b/COPYRIGHT	Mon Nov 17 19:30:27 2008 +0000
@@ -220,6 +220,7 @@
 Tuomas Kuosmanen
 Tero Kuusela
 Richard Laager
+Jacky Lam
 Scott Lamb
 Dennis Lambe Jr.
 Joe LaPenna
--- a/libpurple/dnsquery.c	Mon Nov 17 19:28:39 2008 +0000
+++ b/libpurple/dnsquery.c	Mon Nov 17 19:30:27 2008 +0000
@@ -345,6 +345,12 @@
 {
 	g_return_if_fail(resolver != NULL);
 
+	/* Keep this before the kill() call below. */
+	if (resolver->inpa != 0) {
+		purple_input_remove(resolver->inpa);
+		resolver->inpa = 0;
+	}
+
 	/*
 	 * We might as well attempt to kill our child process.  It really
 	 * doesn't matter if this fails, because children will expire on
@@ -353,9 +359,6 @@
 	if (resolver->dns_pid > 0)
 		kill(resolver->dns_pid, SIGKILL);
 
-	if (resolver->inpa != 0)
-		purple_input_remove(resolver->inpa);
-
 	close(resolver->fd_in);
 	close(resolver->fd_out);