changeset 26850:966d2f2f86c8

Don't crash when the caps cb is NULL and don't corrupt jabber_identities
author Paul Aurich <paul@darkrain42.org>
date Fri, 01 May 2009 18:59:31 +0000
parents 47d03538ee3f
children 6bc0e4e76207 7c1ecd0727db 684690dbda4a
files libpurple/protocols/jabber/caps.c libpurple/protocols/jabber/jabber.c
diffstat 2 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/caps.c	Fri May 01 18:57:44 2009 +0000
+++ b/libpurple/protocols/jabber/caps.c	Fri May 01 18:59:31 2009 +0000
@@ -406,9 +406,11 @@
 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 @@
 	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 @@
 	}
 
 	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);
 }
 
--- a/libpurple/protocols/jabber/jabber.c	Fri May 01 18:57:44 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Fri May 01 18:59:31 2009 +0000
@@ -1807,7 +1807,7 @@
 	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)