pidgin: 21e78118: Don't try to read data from a NULL filen...

qulogic at pidgin.im qulogic at pidgin.im
Sun Sep 7 16:10:29 EDT 2008


-----------------------------------------------------------------
Revision: 21e781181213d3cb9f08fd3e74b9f452ef615f03
Ancestor: 48c5c9c72107408d63250fe0d7feb41f812a5d66
Author: qulogic at pidgin.im
Date: 2008-09-07T19:58:04
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/21e781181213d3cb9f08fd3e74b9f452ef615f03

Modified files:
        libpurple/buddyicon.c libpurple/buddyicon.h

ChangeLog: 

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.

-------------- next part --------------
============================================================
--- libpurple/buddyicon.c	18d12d638239af5082ec913211ade4a888b74af2
+++ libpurple/buddyicon.c	dbb00fa1c7275c14d773a9073830c5d0b41deca2
@@ -934,8 +934,8 @@ purple_buddy_icons_node_set_custom_icon_
 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 @@ purple_buddy_icons_node_set_custom_icon_
 		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);
============================================================
--- libpurple/buddyicon.h	9833d0334d2e344c5b0924db76d2c268d3fb2042
+++ libpurple/buddyicon.h	15012fdc49959c5117aa9eb99b7649574d77db35
@@ -308,7 +308,7 @@ purple_buddy_icons_node_find_custom_icon
  *
  * @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 @@ purple_buddy_icons_node_set_custom_icon(
  * @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.


More information about the Commits mailing list