pidgin: f92d95c8: Don't crash when the caps cb is NULL and...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Fri May 1 16:10:31 EDT 2009


-----------------------------------------------------------------
Revision: f92d95c83baba97463f923077688ba2eb144763b
Ancestor: 617013c6f18c646f381db9955e57a1e1dc6392ea
Author: darkrain42 at pidgin.im
Date: 2009-05-01T18:59:31
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/f92d95c83baba97463f923077688ba2eb144763b

Modified files:
        libpurple/protocols/jabber/caps.c
        libpurple/protocols/jabber/jabber.c

ChangeLog: 

Don't crash when the caps cb is NULL and don't corrupt jabber_identities

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/caps.c	d4701064f2790dc06d6561d92bd8bda2107b0d08
+++ libpurple/protocols/jabber/caps.c	f2b7696da9992a5cea44572ae7c3872482071306
@@ -406,9 +406,11 @@ jabber_caps_get_info_complete(jabber_cap
 static void
 jabber_caps_get_info_complete(jabber_caps_cbplususerdata *userdata)
 {
-	userdata->cb(userdata->info, userdata->exts, userdata->cb_data);
-	userdata->info = NULL;
-	userdata->exts = NULL;
+	if (userdata->cb) {
+		userdata->cb(userdata->info, userdata->exts, userdata->cb_data);
+		userdata->info = NULL;
+		userdata->exts = NULL;
+	}
 
 	if (userdata->ref != 1)
 		purple_debug_warning("jabber", "Lost a reference to caps cbdata: %d\n",
@@ -562,7 +564,8 @@ void jabber_caps_get_info(JabberStream *
 	info = g_hash_table_lookup(capstable, &key);
 	if (info && hash) {
 		/* v1.5 - We already have all the information we care about */
-		cb(info, NULL, user_data);
+		if (cb)
+			cb(info, NULL, user_data);
 		return;
 	}
 
@@ -896,11 +899,12 @@ void jabber_caps_calculate_own_hash(Jabb
 	}
 
 	info.features = features;
-	info.identities = jabber_identities;
+	info.identities = g_list_copy(jabber_identities);
 	info.forms = NULL;
 
 	g_free(js->caps_hash);
 	js->caps_hash = jabber_caps_calculate_hash(&info, "sha1");
+	g_list_free(info.identities);
 	g_list_free(features);
 }
 
============================================================
--- libpurple/protocols/jabber/jabber.c	b4749c545721f6d4a4c7d20eeaab46f0f98d409d
+++ libpurple/protocols/jabber/jabber.c	49078c6a88b3034cce8461eb890c7c0bd16b2d5b
@@ -1807,7 +1807,7 @@ void jabber_add_identity(const gchar *ca
 	ident->type = g_strdup(type);
 	ident->lang = g_strdup(lang);
 	ident->name = g_strdup(name);
-	jabber_identities = g_list_append(jabber_identities, ident);
+	jabber_identities = g_list_prepend(jabber_identities, ident);
 }
 
 static void jabber_identities_destroy(void)


More information about the Commits mailing list