changeset 13894:b9404076ef67

[gaim-migrate @ 16377] Fix a crash bug pointed out by Alexander Sashnov: There is another segfault (on today SVN trunk version). Steps for reproduce: 1. Create jabber account with incorrect params, check it for connect on start up; 2. run Gaim again. It will not connect and see error message in bottom of users list; 3. Open 'accounts' dialog and deselect this account..... segfault :-) committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 30 Jun 2006 06:58:17 +0000
parents ab671b76fb96
children 8f910263b4bb
files src/dnssrv.c src/protocols/jabber/jabber.c
diffstat 2 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/dnssrv.c	Fri Jun 30 03:57:22 2006 +0000
+++ b/src/dnssrv.c	Fri Jun 30 06:58:17 2006 +0000
@@ -275,6 +275,12 @@
 
 #endif
 
+/*
+ * TODO: It would be really good if this returned some sort of handle
+ *       that we could use to cancel the DNS query.  As it is now,
+ *       each callback has to check to make sure gc is still valid.
+ *       And that is ugly.
+ */
 void gaim_srv_resolve(const char *protocol, const char *transport, const char *domain, GaimSRVCallback cb, gpointer extradata) {
 	char *query = g_strdup_printf("_%s._%s.%s",protocol, transport, domain);
 	struct resdata *rdata;
--- a/src/protocols/jabber/jabber.c	Fri Jun 30 03:57:22 2006 +0000
+++ b/src/protocols/jabber/jabber.c	Fri Jun 30 06:58:17 2006 +0000
@@ -481,7 +481,18 @@
 
 static void srv_resolved_cb(GaimSrvResponse *resp, int results, gpointer data)
 {
-	JabberStream *js = (JabberStream*)data;
+	GaimConnection *gc;
+	JabberStream *js;
+
+	gc = data;
+	if (!g_list_find(gaim_connections_get_all(), gc))
+	{
+		/* This connection has been closed */
+		g_free(resp);
+		return;
+	}
+
+	js = (JabberStream*)gc->proto_data;
 
 	if(results) {
 		jabber_login_connect(js, resp->hostname, resp->port);
@@ -561,7 +572,7 @@
 		if(connect_server[0]) {
 			jabber_login_connect(js, connect_server, gaim_account_get_int(account, "port", 5222));
 		} else {
-			gaim_srv_resolve("xmpp-client", "tcp", js->user->domain, srv_resolved_cb, js);
+			gaim_srv_resolve("xmpp-client", "tcp", js->user->domain, srv_resolved_cb, gc);
 		}
 	}
 }