pidgin: 2825cfec: Need to make a copy of the data passed t...

andrew.victor at mxit.com andrew.victor at mxit.com
Mon Sep 5 15:10:48 EDT 2011


----------------------------------------------------------------------
Revision: 2825cfec5e2f9ce0b43361fdd7bdd21c4ea69b24
Parent:   7e83d40baa440a08e5555c3fd790fbb05f9e606a
Author:   andrew.victor at mxit.com
Date:     09/03/11 11:11:20
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/2825cfec5e2f9ce0b43361fdd7bdd21c4ea69b24

Changelog: 

Need to make a copy of the data passed to purple_imgstore_add_with_id().


Changes against parent 7e83d40baa440a08e5555c3fd790fbb05f9e606a

  patched  libpurple/protocols/mxit/formcmds.c
  patched  libpurple/protocols/mxit/protocol.c

-------------- next part --------------
============================================================
--- libpurple/protocols/mxit/formcmds.c	8888c7bc15e7758d2c8fbe9e7a00d214621c08b1
+++ libpurple/protocols/mxit/formcmds.c	6e9d7b11144ceada9a2812cb1e3adb4e004bdc57
@@ -86,7 +86,6 @@ static void mxit_cb_ii_returned(PurpleUt
 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,13 +105,9 @@ static void mxit_cb_ii_returned(PurpleUt
 		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 a copy in the imagestore */
+	id = purple_imgstore_add_with_id(g_memdup(url_text, len), len, NULL);
 
-	/* we now have the inline image, store it in the imagestore */
-	id = purple_imgstore_add_with_id(ii_data, len, NULL);
-
 	/* map the inline image id to purple image id */
 	intptr = g_malloc(sizeof(int));
 	*intptr = id;
============================================================
--- libpurple/protocols/mxit/protocol.c	10dd7e05b590052e1c4055afc7868956ff000c46
+++ libpurple/protocols/mxit/protocol.c	90e530215e393debbf20f654992fb89879108691
@@ -2136,13 +2136,13 @@ static void mxit_parse_cmd_media( struct
 					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 );
 					}
 				}
 			}


More information about the Commits mailing list