/pidgin/main: 7e57fa4513f4: Prevents a segfault caused by a null...

Michael McConville mmcconville at mykolab.com
Sun Aug 9 22:43:14 EDT 2015


Changeset: 7e57fa4513f4f7a85771827c0814a0665a765237
Author:	 Michael McConville <mmcconville at mykolab.com>
Date:	 2015-08-09 22:42 -0400
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/7e57fa4513f4

Description:

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.

diffstat:

 libpurple/buddyicon.c |  22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diffs (34 lines):

diff --git a/libpurple/buddyicon.c b/libpurple/buddyicon.c
--- a/libpurple/buddyicon.c
+++ b/libpurple/buddyicon.c
@@ -254,16 +254,22 @@ purple_buddy_icon_data_new(guchar *icon_
 	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);
 



More information about the Commits mailing list