Crash in dnsquery.c, branch 2.x.y

Thomas Downing <[email protected]> Mon, 18 Dec 2017 07:59:15 -0600
Newsgroups gmane.comp.gnome.gaim.devel
Organization Bomgar
Message-ID <1675852.uyRkyuQOEb@juss>
Hi all,

I am developing an application that uses libpurple.  During development,
I got a repeatable segfault during dns resolution.  I tracked the problem
to initiate_resolving() in dnsquery.c.  The current code fails to call
purple_timeout_remove().  When the timeout callback is later invoked by
my timer code, the gpointer data passed to me by purple_timeout_add()
is no longer valid, causing a segfault.

This is consistently repeatable, and is fixed by the attached patch.  The
patch just adds a call to purple_timeout_remove().

This patch is against branch 2.x.y.

-- 
Thomas Downing

Flon's Law:
    There is not now, and never will be, a language in
which it is the least bit difficult to write bad programs.

_______________________________________________
Devel mailing list
[email protected]
https://pidgin.im/cgi-bin/mailman/listinfo/devel
dnsquery.c.patch (text/x-patch, 321 B)
diff --git a/libpurple/dnsquery.c b/libpurple/dnsquery.c
--- a/libpurple/dnsquery.c
+++ b/libpurple/dnsquery.c
@@ -888,6 +888,8 @@
 	PurpleProxyType proxy_type;
 
 	query_data = data;
+	if (query_data->timeout > 0)
+		purple_timeout_remove(query_data->timeout);
 	query_data->timeout = 0;
 
 	if (resolve_ip(query_data))