comparison libpurple/buddyicon.c @ 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 c01528418cc2
children 72e51db8cac3 175eadaead53
comparison
equal deleted inserted replaced
16536:1c07ce257fd7 16537:42362f23d5a8
96 static char * 96 static char *
97 purple_buddy_icon_data_calculate_filename(guchar *icon_data, size_t icon_len) 97 purple_buddy_icon_data_calculate_filename(guchar *icon_data, size_t icon_len)
98 { 98 {
99 PurpleCipherContext *context; 99 PurpleCipherContext *context;
100 gchar digest[41]; 100 gchar digest[41];
101 const char *ext;
101 102
102 context = purple_cipher_context_new_by_name("sha1", NULL); 103 context = purple_cipher_context_new_by_name("sha1", NULL);
103 if (context == NULL) 104 if (context == NULL)
104 { 105 {
105 purple_debug_error("buddyicon", "Could not find sha1 cipher\n"); 106 purple_debug_error("buddyicon", "Could not find sha1 cipher\n");
113 purple_debug_error("buddyicon", "Failed to get SHA-1 digest.\n"); 114 purple_debug_error("buddyicon", "Failed to get SHA-1 digest.\n");
114 g_return_val_if_reached(NULL); 115 g_return_val_if_reached(NULL);
115 } 116 }
116 purple_cipher_context_destroy(context); 117 purple_cipher_context_destroy(context);
117 118
119 ext = purple_util_get_image_extension(icon_data, icon_len);
120
118 /* Return the filename */ 121 /* Return the filename */
119 return g_strdup_printf("%s.%s", digest, 122 return g_strdup_printf("%s%s%s", digest, ext ? "." : "", ext ? ext : "");
120 purple_util_get_image_extension(icon_data, icon_len));
121 } 123 }
122 124
123 static void 125 static void
124 purple_buddy_icon_data_cache(PurpleStoredImage *img) 126 purple_buddy_icon_data_cache(PurpleStoredImage *img)
125 { 127 {