diff libpurple/protocols/myspace/myspace.c @ 22226:9f95357c21b9

In msim_uid2username_from_blist(), return a static string as the documentation indicates, instead of a string that needs to be freed. Also free the username in msim_add_contacts_from_server_cb(), which is copied from the return value of msim_uid2username_from_blist(). Fixes #4737.
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Tue, 29 Jan 2008 01:51:01 +0000
parents d2fc168b5e7a
children e808d83d797e
line wrap: on
line diff
--- a/libpurple/protocols/myspace/myspace.c	Sun Jan 27 21:37:43 2008 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Tue Jan 29 01:51:01 2008 +0000
@@ -1223,16 +1223,15 @@
  *
  * @param wanted_uid
  *
- * @return Username of wanted_uid, if on blist, or NULL. Static string.
- * 	TODO: The username string here is a new string from g_strdup(), not
- * 	a static string that doesn't need to be fixed. Probably leaks. TODO: fix.
+ * @return Username of wanted_uid, if on blist, or NULL. 
+ * 	This is a static string, so don't free it. Copy it if needed.
  *
  */
 static const gchar *
 msim_uid2username_from_blist(PurpleAccount *account, guint wanted_uid)
 {
 	GSList *buddies, *cur;
-	gchar *ret;
+	const gchar *ret;
 
 	buddies = purple_find_buddies(account, NULL); 
 
@@ -1258,7 +1257,7 @@
 
 		if (uid == wanted_uid)
 		{
-			ret = g_strdup(name);
+			ret = name;
 			break;
 		}
 	}
@@ -2822,8 +2821,9 @@
 	msim_store_user_info(session, contact_info, NULL);
 
 	/* TODO: other fields, store in 'user' */
-
 	msim_msg_free(contact_info);
+
+	g_free(username);
 }
 
 /** Add first ContactID in contact_info to buddy's list. Used to add