changeset 16537:42362f23d5a8

Prevent sprintf(%s, NULL) when the icon type isn't recognized.
author Daniel Atallah <daniel.atallah@gmail.com>
date Fri, 27 Apr 2007 20:21:41 +0000
parents 1c07ce257fd7
children 72e51db8cac3 b33f5b606573 fa8d831e9aa6
files libpurple/buddyicon.c
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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