diff src/protocols/jabber/jabber.c @ 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 25e63008d3bb
children 46be62b128c7
line wrap: on
line diff
--- 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);
 		}
 	}
 }