# HG changeset patch # User Richard Laager # Date 1177818385 0 # Node ID 36a87fb00a22bc4364eb0f13d42b96dc80910910 # Parent 2ef9bdf1a4eb550dd6d6a2c909d88d9564df6332# Parent 898019538f44dff140275422f3dd08fdf0fad66a merge of '2c12ac5fe6f8c8bf07d7bdde347e65c66e4f2de5' and 'e543a2ed3f9f3d48027ac1295d9e5f8e76d9a0f1' diff -r 2ef9bdf1a4eb -r 36a87fb00a22 libpurple/buddyicon.c --- 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); }