changeset 32507:5d81b452dcc4

Need to make a copy of the data passed to purple_imgstore_add_with_id().
author andrew.victor@mxit.com
date Sat, 03 Sep 2011 15:11:20 +0000
parents cadc8dfafbaf
children e21500d61347
files libpurple/protocols/mxit/formcmds.c libpurple/protocols/mxit/protocol.c
diffstat 2 files changed, 4 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/mxit/formcmds.c	Sat Sep 03 11:51:24 2011 +0000
+++ b/libpurple/protocols/mxit/formcmds.c	Sat Sep 03 15:11:20 2011 +0000
@@ -86,7 +86,6 @@
 static void mxit_cb_ii_returned(PurpleUtilFetchUrlData* url_data, gpointer user_data, const gchar* url_text, gsize len, const gchar* error_message)
 {
 	struct ii_url_request*	iireq		= (struct ii_url_request*) user_data;
-	char*					ii_data;
 	int*					intptr		= NULL;
 	int						id;
 
@@ -106,12 +105,8 @@
 		goto done;
 	}
 
-	/* make a copy of the data */
-	ii_data = g_malloc(len);
-	memcpy(ii_data, (const char*) url_text, len);
-
-	/* we now have the inline image, store it in the imagestore */
-	id = purple_imgstore_add_with_id(ii_data, len, NULL);
+	/* we now have the inline image, store a copy in the imagestore */
+	id = purple_imgstore_add_with_id(g_memdup(url_text, len), len, NULL);
 
 	/* map the inline image id to purple image id */
 	intptr = g_malloc(sizeof(int));
--- a/libpurple/protocols/mxit/protocol.c	Sat Sep 03 11:51:24 2011 +0000
+++ b/libpurple/protocols/mxit/protocol.c	Sat Sep 03 15:11:20 2011 +0000
@@ -2136,13 +2136,13 @@
 					contact = get_mxit_invite_contact( session, chunk.mxitid );
 					if ( contact ) {
 						/* this is an invite (add image to the internal image store) */
-						contact->imgid = purple_imgstore_add_with_id( chunk.data, chunk.length, NULL );
+						contact->imgid = purple_imgstore_add_with_id( g_memdup( chunk.data, chunk.length ), chunk.length, NULL );
 						/* show the profile */
 						mxit_show_profile( session, chunk.mxitid, contact->profile );
 					}
 					else {
 						/* this is a contact's avatar, so update it */
-						purple_buddy_icons_set_for_user( session->acc, chunk.mxitid, g_memdup( chunk.data, chunk.length), chunk.length, chunk.avatarid );
+						purple_buddy_icons_set_for_user( session->acc, chunk.mxitid, g_memdup( chunk.data, chunk.length ), chunk.length, chunk.avatarid );
 					}
 				}
 			}