changeset 20940:d1695d02c498

Fix CID 308, which was an error about code which could not be reached. I think this is the right fix, though I think that means that buddy icons were never being deleted properly.
author Richard Laager <rlaager@wiktel.com>
date Mon, 15 Oct 2007 00:47:48 +0000
parents f56e94167372
children 65d19253f746 e0d7429cfd8a
files libpurple/buddyicon.c
diffstat 1 files changed, 23 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/buddyicon.c	Sun Oct 14 20:35:13 2007 +0000
+++ b/libpurple/buddyicon.c	Mon Oct 15 00:47:48 2007 +0000
@@ -505,37 +505,33 @@
 		purple_buddy_icon_set_data(icon, icon_data, icon_len, checksum);
 	else if (icon_data && icon_len > 0)
 	{
-		if (icon_data != NULL && icon_len > 0)
-		{
-			PurpleBuddyIcon *icon = purple_buddy_icon_new(account, username, icon_data, icon_len, checksum);
+		PurpleBuddyIcon *icon = purple_buddy_icon_new(account, username, icon_data, icon_len, checksum);
 
-			/* purple_buddy_icon_new() calls
-			 * purple_buddy_icon_set_data(), which calls
-			 * purple_buddy_icon_update(), which has the buddy list
-			 * and conversations take references as appropriate.
-			 * This function doesn't return icon, so we can't
-			 * leave a reference dangling. */
-			purple_buddy_icon_unref(icon);
-		}
-		else
+		/* purple_buddy_icon_new() calls
+		 * purple_buddy_icon_set_data(), which calls
+		 * purple_buddy_icon_update(), which has the buddy list
+		 * and conversations take references as appropriate.
+		 * This function doesn't return icon, so we can't
+		 * leave a reference dangling. */
+		purple_buddy_icon_unref(icon);
+	}
+	else
+	{
+		/* If the buddy list or a conversation was holding a
+		 * reference, we'd have found the icon in the cache.
+		 * Since we know we're deleting the icon, we only
+		 * need a subset of purple_buddy_icon_update(). */
+
+		GSList *buddies = purple_find_buddies(account, username);
+		while (buddies != NULL)
 		{
-			/* If the buddy list or a conversation was holding a
-			 * reference, we'd have found the icon in the cache.
-			 * Since we know we're deleting the icon, we only
-			 * need a subset of purple_buddy_icon_update(). */
+			PurpleBuddy *buddy = (PurpleBuddy *)buddies->data;
 
-			GSList *buddies = purple_find_buddies(account, username);
-			while (buddies != NULL)
-			{
-				PurpleBuddy *buddy = (PurpleBuddy *)buddies->data;
+			unref_filename(purple_blist_node_get_string((PurpleBlistNode *)buddy, "buddy_icon"));
+			purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "buddy_icon");
+			purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "icon_checksum");
 
-				unref_filename(purple_blist_node_get_string((PurpleBlistNode *)buddy, "buddy_icon"));
-				purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "buddy_icon");
-				purple_blist_node_remove_setting((PurpleBlistNode *)buddy, "icon_checksum");
-
-				buddies = g_slist_delete_link(buddies, buddies);
-			}
-
+			buddies = g_slist_delete_link(buddies, buddies);
 		}
 	}
 }