/soc/2012/michael/android: 735666ea1533: Made blist use purple_b...

Michael Zangl michael at soc.pidgin.im
Tue Jul 17 11:16:54 EDT 2012


Changeset: 735666ea15333e15df21122583334b6f4c81a9e0
Author:	 Michael Zangl <michael at soc.pidgin.im>
Date:	 2012-07-17 17:01 +0200
Branch:	 default
URL: http://hg.pidgin.im/soc/2012/michael/android/rev/735666ea1533

Description:

Made blist use purple_blist_get_root to avoid uncontrolled crashes if no blist was set.

diffstat:

 libpurple/blist.c |  18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diffs (77 lines):

diff --git a/libpurple/blist.c b/libpurple/blist.c
--- a/libpurple/blist.c
+++ b/libpurple/blist.c
@@ -767,7 +767,9 @@
 PurpleBlistNode *
 purple_blist_get_root()
 {
-	return purplebuddylist ? purplebuddylist->root : NULL;
+	g_return_val_if_fail(purplebuddylist != NULL, NULL);
+	
+	return purplebuddylist->root;
 }
 
 static void
@@ -1486,7 +1488,7 @@
 		/* Add group to blist if isn't already on it. Fixes #2752. */
 		if (!purple_find_group(group->name)) {
 			purple_blist_add_group(group,
-					purple_blist_get_last_sibling(purplebuddylist->root));
+					purple_blist_get_last_sibling(purple_blist_get_root()));
 		}
 	} else {
 		group = (PurpleGroup*)node->parent;
@@ -1589,7 +1591,7 @@
 		/* Add group to blist if isn't already on it. Fixes #2752. */
 		if (!purple_find_group(g->name)) {
 			purple_blist_add_group(g,
-					purple_blist_get_last_sibling(purplebuddylist->root));
+					purple_blist_get_last_sibling(purple_blist_get_root()));
 		}
 		c = purple_contact_new();
 		purple_blist_add_contact(c, g,
@@ -1839,7 +1841,7 @@
 		if (g == NULL) {
 			g = purple_group_new(_("Buddies"));
 			purple_blist_add_group(g,
-					purple_blist_get_last_sibling(purplebuddylist->root));
+					purple_blist_get_last_sibling(purple_blist_get_root()));
 		}
 	}
 
@@ -2462,7 +2464,7 @@
 		hb.name = (gchar *)purple_normalize(account, name);
 		hb.account = account;
 
-		for (node = purplebuddylist->root; node != NULL; node = node->next) {
+		for (node = purple_blist_get_root(); node != NULL; node = node->next) {
 			if (!node->child)
 				continue;
 
@@ -2520,7 +2522,7 @@
 		return prpl_info->find_blist_chat(account, name);
 
 	normname = g_strdup(purple_normalize(account, name));
-	for (group = purplebuddylist->root; group != NULL; group = group->next) {
+	for (group = purple_blist_get_root(); group != NULL; group = group->next) {
 		for (node = group->child; node != NULL; node = node->next) {
 			if (PURPLE_BLIST_NODE_IS_CHAT(node)) {
 
@@ -2644,7 +2646,7 @@
 	if (!ops || !ops->update)
 		return;
 
-	for (gnode = purplebuddylist->root; gnode; gnode = gnode->next) {
+	for (gnode = purple_blist_get_root(); gnode; gnode = gnode->next) {
 		if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
 			continue;
 		for (cnode = gnode->child; cnode; cnode = cnode->next) {
@@ -2688,7 +2690,7 @@
 
 	g_return_if_fail(purplebuddylist != NULL);
 
-	for (gnode = purplebuddylist->root; gnode; gnode = gnode->next) {
+	for (gnode = purple_blist_get_root(); gnode; gnode = gnode->next) {
 		if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
 			continue;
 



More information about the Commits mailing list