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

Michael McConville <[email protected]>
Newsgroups gmane.comp.gnome.gaim.cvs
Message-ID <[email protected]>
Changeset: 7e57fa4513f4f7a85771827c0814a0665a765237
Author:	 Michael McConville <[email protected]>
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);
 

_______________________________________________
Commits mailing list
[email protected]
https://pidgin.im/cgi-bin/mailman/listinfo/commits
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.