# HG changeset patch # User Richard Laager # Date 1226950227 0 # Node ID 002a58d4af7d56a429a8ea3b938c579f8581461f # Parent e5efa83aa6d22763d53ad19694a84204b906ddf7 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!! diff -r e5efa83aa6d2 -r 002a58d4af7d COPYRIGHT --- 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 diff -r e5efa83aa6d2 -r 002a58d4af7d libpurple/dnsquery.c --- 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);