changeset 16631:36a87fb00a22

merge of '2c12ac5fe6f8c8bf07d7bdde347e65c66e4f2de5' and 'e543a2ed3f9f3d48027ac1295d9e5f8e76d9a0f1'
author Richard Laager <rlaager@wiktel.com>
date Sun, 29 Apr 2007 03:46:25 +0000
parents 2ef9bdf1a4eb (current diff) 898019538f44 (diff)
children 787d57d5d6ed 2b12b143a529
files libpurple/buddyicon.c
diffstat 1 files changed, 21 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/buddyicon.c	Sun Apr 29 02:52:34 2007 +0000
+++ b/libpurple/buddyicon.c	Sun Apr 29 03:46:25 2007 +0000
@@ -212,6 +212,10 @@
 {
 	const char *filename = purple_imgstore_get_filename(img);
 
+	/* If there's no filename, it can't be one of our images. */
+	if (filename == NULL)
+		return;
+
 	if (img == g_hash_table_lookup(icon_data_cache, filename))
 	{
 		purple_buddy_icon_data_uncache_file(filename);
@@ -908,9 +912,19 @@
 		FILE *file;
 		char *new_filename;
 
-		if (!read_icon_file(path, &icon_data, &icon_len) ||
-		    icon_data == NULL || icon_len <= 0)
+		if (!read_icon_file(path, &icon_data, &icon_len))
 		{
+			g_free(path);
+			delete_buddy_icon_settings(node, setting_name);
+			return;
+		}
+
+		if (icon_data == NULL || icon_len <= 0)
+		{
+			/* This really applies to the icon_len check.
+			 * icon_data should never be NULL if
+			 * read_icon_file() returns TRUE. */
+			purple_debug_error("buddyicon", "Empty buddy icon file: %s\n", path);
 			delete_buddy_icon_settings(node, setting_name);
 			g_free(path);
 			return;
@@ -921,8 +935,11 @@
 		new_filename = purple_buddy_icon_data_calculate_filename(icon_data, icon_len);
 		if (new_filename == NULL)
 		{
+			purple_debug_error("buddyicon",
+				"New icon filename is NULL. This should never happen! "
+				"The old filename was: %s\n", path);
 			delete_buddy_icon_settings(node, setting_name);
-			return;
+			g_return_if_reached();
 		}
 
 		path = g_build_filename(dirname, new_filename, NULL);
@@ -988,7 +1005,7 @@
 	}
 	else
 	{
-		/* If the icon is gone, drop the setting... */
+		purple_debug_error("buddyicon", "Old icon file doesn't exist: %s\n", path);
 		delete_buddy_icon_settings(node, setting_name);
 		g_free(path);
 	}