Prevent sprintf(%s, NULL) when the icon type isn't recognized.

Fri, 27 Apr 2007 20:21:41 +0000

author
Daniel Atallah <datallah@pidgin.im>
date
Fri, 27 Apr 2007 20:21:41 +0000
changeset 16597
08684c31d2e9
parent 16596
92be5d0abd43
child 16598
05b760265bf9
child 16601
591629978962
child 16604
b21351a48b9f

Prevent sprintf(%s, NULL) when the icon type isn't recognized.

libpurple/buddyicon.c file | annotate | diff | comparison | revisions
--- a/libpurple/buddyicon.c	Fri Apr 27 18:56:41 2007 +0000
+++ b/libpurple/buddyicon.c	Fri Apr 27 20:21:41 2007 +0000
@@ -98,6 +98,7 @@
 {
 	PurpleCipherContext *context;
 	gchar digest[41];
+	const char *ext;
 
 	context = purple_cipher_context_new_by_name("sha1", NULL);
 	if (context == NULL)
@@ -115,9 +116,10 @@
 	}
 	purple_cipher_context_destroy(context);
 
+	ext = purple_util_get_image_extension(icon_data, icon_len);
+
 	/* Return the filename */
-	return g_strdup_printf("%s.%s", digest,
-	                       purple_util_get_image_extension(icon_data, icon_len));
+	return g_strdup_printf("%s%s%s", digest, ext ? "." : "", ext ? ext : "");
 }
 
 static void

mercurial