Crash at purple_dnsquery_destroy()

Jacky Lam jackylam at gsl.com.hk
Thu Nov 6 02:21:59 EST 2008


Dear all,

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!!

My solution is simple. Just reverse the older to free the object will be ok.

Origin code:

if (resolver->dns_pid > 0)
kill(resolver->dns_pid, SIGKILL);

if (resolver->inpa != 0)
purple_input_remove(resolver->inpa);


Fixed code:

if (resolver->inpa != 0)
{
purple_input_remove(resolver->inpa);
resolver->inpa=0;
}

if (resolver->dns_pid > 0)
kill(resolver->dns_pid, SIGKILL);

I don't know if it applies to all platform nor it has better way to do
that, but hope it is useful to others having this problem.

Thanks.

BR,
Jacky




More information about the Devel mailing list