changeset 24770:22fd7467f0cc

Fix a few small memleaks
author Mark Doliner <mark@kingant.net>
date Thu, 18 Dec 2008 01:53:49 +0000
parents 29931785a68a
children 8fb78d30ea83
files libpurple/protocols/myspace/message.c libpurple/protocols/myspace/myspace.c libpurple/protocols/myspace/user.c
diffstat 3 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/myspace/message.c	Wed Dec 17 22:37:53 2008 +0000
+++ b/libpurple/protocols/myspace/message.c	Thu Dec 18 01:53:49 2008 +0000
@@ -1040,7 +1040,7 @@
 			/* Incoming protocol messages get tagged as MSIM_TYPE_RAW, which
 			 * represents an untyped piece of data. msim_msg_get_* will
 			 * convert to appropriate types for caller, and handle unescaping if needed. */
-			msg = msim_msg_append(msg, g_strdup(key), MSIM_TYPE_RAW, g_strdup(value));
+			msg = msim_msg_append_dynamic_name(msg, g_strdup(key), MSIM_TYPE_RAW, g_strdup(value));
 #ifdef MSIM_DEBUG_PARSE
 			purple_debug_info("msim", "insert string: |%s|=|%s|\n", key, value);
 #endif
--- a/libpurple/protocols/myspace/myspace.c	Wed Dec 17 22:37:53 2008 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Thu Dec 18 01:53:49 2008 +0000
@@ -1380,17 +1380,15 @@
 	if (status_headline && strcmp(status_headline, "") != 0) {
 		/* The status headline is plaintext, but libpurple treats it as HTML,
 		 * so escape any HTML characters to their entity equivalents. */
-		status_headline_escaped = g_markup_escape_text(status_headline, strlen(status_headline));
+		status_headline_escaped = g_markup_escape_text(status_headline, -1);
 	} else {
 		status_headline_escaped = NULL;
 	}
 
 	g_free(status_headline);
 
-	if (user->headline)
-		g_free(user->headline);
-
 	/* don't copy; let the MsimUser own the headline, memory-wise */
+	g_free(user->headline);
 	user->headline = status_headline_escaped;
 
 	/* Set user status */
@@ -1421,7 +1419,6 @@
 					status_code);
 			msim_unrecognized(session, NULL, unrecognized_msg);
 			g_free(unrecognized_msg);
-
 	}
 
 	purple_prpl_got_user_status(session->account, username, purple_primitive_get_id_from_type(purple_status_code), NULL);
--- a/libpurple/protocols/myspace/user.c	Wed Dec 17 22:37:53 2008 +0000
+++ b/libpurple/protocols/myspace/user.c	Thu Dec 18 01:53:49 2008 +0000
@@ -286,6 +286,7 @@
 	if (g_str_equal(key_str, "UserID") || g_str_equal(key_str, "ContactID")) {
 		/* Save to buddy list, if it exists, for quick cached uid lookup with msim_uid2username_from_blist(). */
 		user->id = atol(value_str);
+		g_free(value_str);
 		if (user->buddy)
 		{
 			purple_debug_info("msim", "associating uid %s with username %s\n", key_str, user->buddy->name);
@@ -303,13 +304,16 @@
 		user->location = value_str;
 	} else if (g_str_equal(key_str, "TotalFriends")) {
 		user->total_friends = atol(value_str);
+		g_free(value_str);
 	} else if (g_str_equal(key_str, "DisplayName")) {
 		g_free(user->display_name);
 		user->display_name = value_str;
 	} else if (g_str_equal(key_str, "BandName")) {
 		msim_set_artist_or_title(user, value_str, NULL);
+		g_free(value_str);
 	} else if (g_str_equal(key_str, "SongName")) {
 		msim_set_artist_or_title(user, NULL, value_str);
+		g_free(value_str);
 	} else if (g_str_equal(key_str, "UserName") || g_str_equal(key_str, "IMName") || g_str_equal(key_str, "NickName")) {
 		/* Ignore because PurpleBuddy knows this already */
 		g_free(value_str);