# HG changeset patch # User andrew.victor@mxit.com # Date 1315062680 0 # Node ID 5d81b452dcc42c2fbd984ce5defa0360ca8a0910 # Parent cadc8dfafbafaaf87a7a8b22bcc97581fa8a58ae Need to make a copy of the data passed to purple_imgstore_add_with_id(). diff -r cadc8dfafbaf -r 5d81b452dcc4 libpurple/protocols/mxit/formcmds.c --- 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)); diff -r cadc8dfafbaf -r 5d81b452dcc4 libpurple/protocols/mxit/protocol.c --- 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 ); } } }