changeset 16505:2ae39a056179

GINT_TO_POINTER is not the same thing as &. Also, add some error checking to jabber/buddy.c
author Sean Egan <seanegan@gmail.com>
date Fri, 27 Apr 2007 05:32:49 +0000
parents 089531c08d75
children e4a1980c0090 f2332c0da79f
files libpurple/imgstore.c libpurple/protocols/jabber/buddy.c
diffstat 2 files changed, 19 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/imgstore.c	Fri Apr 27 04:40:22 2007 +0000
+++ b/libpurple/imgstore.c	Fri Apr 27 05:32:49 2007 +0000
@@ -71,13 +71,13 @@
 	PurpleStoredImage *img = purple_imgstore_add(data, size, filename);
 	img->id = ++nextid;
 
-	g_hash_table_insert(imgstore, GINT_TO_POINTER(img->id), img);
+	g_hash_table_insert(imgstore, &(img->id), img);
 
 	return img->id;
 }
 
 PurpleStoredImage *purple_imgstore_find_by_id(int id) {
-	PurpleStoredImage *img = g_hash_table_lookup(imgstore, GINT_TO_POINTER(id));
+	PurpleStoredImage *img = g_hash_table_lookup(imgstore, &id);
 
 	if (img != NULL)
 		purple_debug_misc("imgstore", "retrieved image id %d\n", img->id);
@@ -155,7 +155,7 @@
 		purple_signal_emit(purple_imgstore_get_handle(),
 		                   "image-deleting", img);
 		if (img->id)
-			g_hash_table_remove(imgstore, GINT_TO_POINTER(img->id));
+			g_hash_table_remove(imgstore, &img->id);
 
 		g_free(img->data);
 		g_free(img->filename);
--- a/libpurple/protocols/jabber/buddy.c	Fri Apr 27 04:40:22 2007 +0000
+++ b/libpurple/protocols/jabber/buddy.c	Fri Apr 27 05:32:49 2007 +0000
@@ -955,22 +955,23 @@
 					gboolean photo = (strcmp(child->name, "PHOTO") == 0);
 
 					data = purple_base64_decode(bintext, &size);
-
-					jbi->vcard_imgids = g_slist_prepend(jbi->vcard_imgids, GINT_TO_POINTER(purple_imgstore_add_with_id(g_memdup(data, size), size, "logo.png")));
-					g_string_append_printf(info_text,
-							"<b>%s:</b> <img id='%d'><br/>",
-							photo ? _("Photo") : _("Logo"),
-							GPOINTER_TO_INT(jbi->vcard_imgids->data));
+					if (data) {
+						jbi->vcard_imgids = g_slist_prepend(jbi->vcard_imgids, GINT_TO_POINTER(purple_imgstore_add_with_id(g_memdup(data, size), size, "logo.png")));
+						g_string_append_printf(info_text,
+								"<b>%s:</b> <img id='%d'><br/>",
+								photo ? _("Photo") : _("Logo"),
+								GPOINTER_TO_INT(jbi->vcard_imgids->data));
+	
+						purple_cipher_digest_region("sha1", (guchar *)data, size,
+								sizeof(hashval), hashval, NULL);
+						p = hash;
+						for(i=0; i<20; i++, p+=2)
+							snprintf(p, 3, "%02x", hashval[i]);
 
-					purple_cipher_digest_region("sha1", (guchar *)data, size,
-							sizeof(hashval), hashval, NULL);
-					p = hash;
-					for(i=0; i<20; i++, p+=2)
-						snprintf(p, 3, "%02x", hashval[i]);
-
-					purple_buddy_icons_set_for_user(js->gc->account, bare_jid,
-							data, size, hash);
-					g_free(bintext);
+						purple_buddy_icons_set_for_user(js->gc->account, bare_jid,
+								data, size, hash);
+						g_free(bintext);
+					}
 				}
 			}
 			g_free(text);