comparison libpurple/protocols/myspace/user.c @ 20982:aee8d876fed1

When getting info on a myspace user not on the buddy list, a temporary PurpleBuddy is needed so that the data can be associated properly. This fixes a bug wherein the profile link went to http://myspace.com/0 for all buddies not on the list. A check against that uid being 0 has also been added to avoid displaying junk data. Such temporary MsimUser objects (note that the temporariness of MsimUser objects is unchanged; a temporary PurpleBuddy has just been added to go with it) are destroyed before a delayed callback can be triggerred. This means that we can not request a buddy icon on that object, because we will end up with a pointer to freed data in the callback some time in the future. This fixes a crash when getting info on a non-buddy list buddy (which for reasons I can't pinpoint was most likely if the username contained capital letters). A reference counting system for MsimUser objects would fix this but is a significantly more complex solution.
author Evan Schoenberg <evan.s@dreskin.net>
date Thu, 18 Oct 2007 12:01:41 +0000
parents 61045691aa72
children 87c9d114864b
comparison
equal deleted inserted replaced
20981:145ee1570fc0 20982:aee8d876fed1
97 97
98 uid = purple_blist_node_get_int(&user->buddy->node, "UserID"); 98 uid = purple_blist_node_get_int(&user->buddy->node, "UserID");
99 99
100 if (full) { 100 if (full) {
101 /* TODO: link to username, if available */ 101 /* TODO: link to username, if available */
102 char *profile = g_strdup_printf("<a href=\"http://myspace.com/%d\">http://myspace.com/%d</a>", 102 if (uid) {
103 uid, uid); 103 char *profile = g_strdup_printf("<a href=\"http://myspace.com/%d\">http://myspace.com/%d</a>",
104 purple_notify_user_info_add_pair(user_info, _("Profile"), profile); 104 uid, uid);
105 g_free(profile); 105 purple_notify_user_info_add_pair(user_info, _("Profile"), profile);
106 g_free(profile);
107 }
106 } 108 }
107 109
108 110
109 /* a/s/l...the vitals */ 111 /* a/s/l...the vitals */
110 if (user->age) { 112 if (user->age) {
199 user->song_name = value_str; 201 user->song_name = value_str;
200 } else if (g_str_equal(key_str, "UserName") || g_str_equal(key_str, "IMName") || g_str_equal(key_str, "NickName")) { 202 } else if (g_str_equal(key_str, "UserName") || g_str_equal(key_str, "IMName") || g_str_equal(key_str, "NickName")) {
201 /* Ignore because PurpleBuddy knows this already */ 203 /* Ignore because PurpleBuddy knows this already */
202 g_free(value_str); 204 g_free(value_str);
203 } else if (g_str_equal(key_str, "ImageURL") || g_str_equal(key_str, "AvatarURL")) { 205 } else if (g_str_equal(key_str, "ImageURL") || g_str_equal(key_str, "AvatarURL")) {
206 if (user->temporary_user) {
207 /* This user will be destroyed soon; don't try to look up its image or avatar,
208 * since that won't return immediately and we will end up accessing freed data.
209 */
210 g_free(value_str);
211 return;
212 }
213
204 const gchar *previous_url; 214 const gchar *previous_url;
205 215
206 g_free(user->image_url); 216 g_free(user->image_url);
207 217
208 user->image_url = value_str; 218 user->image_url = value_str;