changeset 24074:2ecdd0403dc1

Don't try to read data from a NULL filename in purple_buddy_icons_node_set_custom_icon_from_file. Also document that you can use NULL to unset the icon. Fixes #6998.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sun, 07 Sep 2008 19:58:04 +0000
parents eb4d0636cf88
children fa39c801167d
files libpurple/buddyicon.c libpurple/buddyicon.h
diffstat 2 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/buddyicon.c	Sun Sep 07 19:08:04 2008 +0000
+++ b/libpurple/buddyicon.c	Sun Sep 07 19:58:04 2008 +0000
@@ -934,8 +934,8 @@
 purple_buddy_icons_node_set_custom_icon_from_file(PurpleBlistNode *node,
                                                   const gchar *filename)
 {
-	size_t len;
-	guchar *data;
+	size_t len = 0;
+	guchar *data = NULL;
 
 	g_return_val_if_fail(node != NULL, NULL);
 
@@ -945,8 +945,10 @@
 		return NULL;
 	}
 
-	if (!read_icon_file(filename, &data, &len)) {
-		return NULL;
+	if (filename != NULL) {
+		if (!read_icon_file(filename, &data, &len)) {
+			return NULL;
+		}
 	}
 
 	return purple_buddy_icons_node_set_custom_icon(node, data, len);
--- a/libpurple/buddyicon.h	Sun Sep 07 19:08:04 2008 +0000
+++ b/libpurple/buddyicon.h	Sun Sep 07 19:58:04 2008 +0000
@@ -308,7 +308,7 @@
  *
  * @param node      The blist node for which to set a custom icon.
  * @param icon_data The image data of the icon, which the buddy icon code will
- *                  free.
+ *                  free. Use NULL to unset the icon.
  * @param icon_len  The length of the data in @a icon_data.
  *
  * @return The icon that was set. The caller does NOT own a reference to this,
@@ -326,7 +326,8 @@
  * @see purple_buddy_icons_node_set_custom_icon()
  *
  * @param node      The blist node for which to set a custom icon.
- * @param filename  The path to the icon to set for the blist node.
+ * @param filename  The path to the icon to set for the blist node. Use NULL
+ *                  to unset the custom icon.
  *
  * @return The icon that was set. The caller does NOT own a reference to this,
  *         and must call purple_imgstore_ref() if it wants one.