diff options
author | Michael McConville <mmcconville@mykolab.com> | 2015-08-09 22:42:34 -0400 |
---|---|---|
committer | Michael McConville <mmcconville@mykolab.com> | 2015-08-09 22:42:34 -0400 |
commit | da72ec3ac9951e963b4b6bbe708524e6cc008b97 (patch) | |
tree | 7d6343adfc5c71dd1822a51649e9b221cf227543 | |
parent | 1b5191a608bf3e267b67a8448108a0509d663731 (diff) | |
download | pidgin-da72ec3ac9951e963b4b6bbe708524e6cc008b97.tar.gz |
Prevents a segfault caused by a null filename. This caused frequent but nondeterministic crashes on startup when run on OpenBSD. Buddy icons seem to render fine when this check is added.
-rw-r--r-- | libpurple/buddyicon.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/libpurple/buddyicon.c b/libpurple/buddyicon.c index 22b16b4ab0..0bdbc8d711 100644 --- a/libpurple/buddyicon.c +++ b/libpurple/buddyicon.c @@ -254,16 +254,22 @@ purple_buddy_icon_data_new(guchar *icon_data, size_t icon_len) newimg = purple_image_new_from_data(icon_data, icon_len); filename = purple_image_generate_filename(newimg); - oldimg = g_hash_table_lookup(icon_data_cache, filename); - if (oldimg) { - g_warn_if_fail(PURPLE_IS_IMAGE(oldimg)); - g_object_unref(newimg); - g_object_ref(oldimg); - return oldimg; + /* TODO: Why is this function called for buddies without icons? If this is + * intended, should the filename be null? + */ + if (filename != NULL) { + oldimg = g_hash_table_lookup(icon_data_cache, filename); + if (oldimg) { + g_warn_if_fail(PURPLE_IS_IMAGE(oldimg)); + g_object_unref(newimg); + g_object_ref(oldimg); + return oldimg; + } + + /* This will take ownership of file and free it as needed */ + g_hash_table_insert(icon_data_cache, g_strdup(filename), newimg); } - /* This will take ownership of file and free it as needed */ - g_hash_table_insert(icon_data_cache, g_strdup(filename), newimg); g_object_set_data_full(G_OBJECT(newimg), "purple-buddyicon-filename", g_strdup(filename), image_deleting_cb); |