# HG changeset patch
# Node ID 3d0c34cf31b8
# Parent  0dbc0e0d4386
diff --git a/finch/plugins/gnttinyurl.c b/finch/plugins/gnttinyurl.c
--- a/finch/plugins/gnttinyurl.c
+++ b/finch/plugins/gnttinyurl.c
@@ -274,8 +274,7 @@ static gboolean writing_msg(PurpleAccoun
 			urls = g_list_delete_link(urls, iter);
 		}
 	}
-	*message = t->str;
-	g_string_free(t, FALSE);
+	*message = g_string_free(t, FALSE);
 	if (conv == NULL)
 		conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, sender);
 	purple_conversation_set_data(conv, "TinyURLs", urls);
diff --git a/libpurple/media/codec.c b/libpurple/media/codec.c
--- a/libpurple/media/codec.c
+++ b/libpurple/media/codec.c
@@ -388,7 +388,6 @@ purple_media_codec_to_string(const Purpl
 	PurpleMediaCodecPrivate *priv;
 	GString *string = NULL;
 	GList *item;
-	gchar *charstring;
 	const gchar *media_type_str = NULL;
 
 	if (codec == NULL)
@@ -415,9 +414,6 @@ purple_media_codec_to_string(const Purpl
 				param->key, (gchar *)param->value);
 	}
 
-	charstring = string->str;
-	g_string_free (string, FALSE);
-
-	return charstring;
+	return g_string_free(string, FALSE);
 }
 
diff --git a/libpurple/plugins/log_reader.c b/libpurple/plugins/log_reader.c
--- a/libpurple/plugins/log_reader.c
+++ b/libpurple/plugins/log_reader.c
@@ -444,7 +444,6 @@ struct msn_logger_data {
 	xmlnode *message;
 	const char *session_id;
 	int last_log;
-	GString *text;
 };
 
 /* This function is really confusing.  It makes baby rlaager cry...
@@ -865,7 +864,6 @@ static GList *msn_logger_list(PurpleLogT
 			data->root = root;
 			data->message = message;
 			data->session_id = session_id;
-			data->text = NULL;
 			data->last_log = FALSE;
 
 			stamp = msn_logger_parse_timestamp(message, &tm);
@@ -897,24 +895,14 @@ static char * msn_logger_read (PurpleLog
 
 	data = log->logger_data;
 
-	if (data->text) {
-		/* The GTK code which displays the logs g_free()s whatever is
-		 * returned from this function. Thus, we can't reuse the str
-		 * part of the GString. The only solution is to free it and
-		 * start over.
-		 */
-		g_string_free(data->text, FALSE);
-	}
-
 	text = g_string_new("");
 
 	if (!data->root || !data->message || !data->session_id) {
 		/* Something isn't allocated correctly. */
 		purple_debug_error("MSN log parse",
 		                   "Error parsing message: %s\n", "Internal variables inconsistent");
-		data->text = text;
-
-		return text->str;
+
+		return g_string_free(text, FALSE);
 	}
 
 	for (message = data->message; message;
@@ -1157,9 +1145,7 @@ static char * msn_logger_read (PurpleLog
 		g_free(tmp);
 	}
 
-	data->text = text;
-
-	return text->str;
+	return g_string_free(text, FALSE);
 }
 
 static int msn_logger_size (PurpleLog *log)
@@ -1190,9 +1176,6 @@ static void msn_logger_finalize(PurpleLo
 	if (data->last_log)
 		xmlnode_free(data->root);
 
-	if (data->text)
-		g_string_free(data->text, FALSE);
-
 	g_free(data);
 }
 
diff --git a/libpurple/protocols/gg/gg.c b/libpurple/protocols/gg/gg.c
--- a/libpurple/protocols/gg/gg.c
+++ b/libpurple/protocols/gg/gg.c
@@ -1146,8 +1146,7 @@ static void ggp_recv_message_handler(Pur
 			}
 		}
 
-		msg = message->str;
-		g_string_free(message, FALSE);
+		msg = g_string_free(message, FALSE);
 
 		if (got_image) {
 			info->pending_richtext_messages = g_list_append(info->pending_richtext_messages, msg);
diff --git a/libpurple/protocols/sametime/sametime.c b/libpurple/protocols/sametime/sametime.c
--- a/libpurple/protocols/sametime/sametime.c
+++ b/libpurple/protocols/sametime/sametime.c
@@ -3932,10 +3932,7 @@ static char *im_mime_convert(PurpleConne
 
   str = g_string_new(NULL);
   purple_mime_document_write(doc, str);
-  tmp = str->str;
-  g_string_free(str, FALSE);
-
-  return tmp;
+  return g_string_free(str, FALSE);
 }
 
 
diff --git a/libpurple/protocols/silc10/util.c b/libpurple/protocols/silc10/util.c
--- a/libpurple/protocols/silc10/util.c
+++ b/libpurple/protocols/silc10/util.c
@@ -534,12 +534,11 @@ silcpurple_parse_attrs(SilcDList attrs, 
 		if (mood & SILC_ATTRIBUTE_MOOD_ANXIOUS)
 			g_string_append_printf(s, "[%s] ", _("Anxious"));
 	}
-	if (strlen(s->str)) {
-		*moodstr = s->str;
-		g_string_free(s, FALSE);
-		g_strchomp(*moodstr);
-	} else
+	if (s->len != 0) {
+		*moodstr = g_strchomp(g_string_free(s, FALSE));
+	} else {
 		g_string_free(s, TRUE);
+	}
 
 	attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_STATUS_FREETEXT);
 	memset(tmp, 0, sizeof(tmp));
@@ -564,12 +563,11 @@ silcpurple_parse_attrs(SilcDList attrs, 
 		if (contact & SILC_ATTRIBUTE_CONTACT_VIDEO)
 			g_string_append_printf(s, "[%s] ", _("Video Conferencing"));
 	}
-	if (strlen(s->str)) {
-		*contactstr = s->str;
-		g_string_free(s, FALSE);
-		g_strchomp(*contactstr);
-	} else
+	if (s->len != 0) {
+		*contactstr = g_strchomp(g_string_free(s, FALSE));
+	} else {
 		g_string_free(s, TRUE);
+	}
 
 	attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_PREFERRED_LANGUAGE);
 	memset(tmp, 0, sizeof(tmp));
@@ -594,11 +592,11 @@ silcpurple_parse_attrs(SilcDList attrs, 
 				device.model ? device.model : "",
 				device.language ? device.language : "");
 	}
-	if (strlen(s->str)) {
-		*devicestr = s->str;
-		g_string_free(s, FALSE);
-	} else
+	if (s->len != 0) {
+		*devicestr = g_string_free(s, FALSE);
+	} else {
 		g_string_free(s, TRUE);
+	}
 
 	attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_TIMEZONE);
 	memset(tmp, 0, sizeof(tmp));
diff --git a/libpurple/protocols/zephyr/zephyr.c b/libpurple/protocols/zephyr/zephyr.c
--- a/libpurple/protocols/zephyr/zephyr.c
+++ b/libpurple/protocols/zephyr/zephyr.c
@@ -600,8 +600,7 @@ static char *html_to_zephyr(const char *
 			g_string_append_c(frames->text, *message++);
 		}
 	}
-	ret = frames->text->str;
-	g_string_free(frames->text, FALSE);
+	ret = g_string_free(frames->text, FALSE);
 	g_free(frames);
 	purple_debug_info("zephyr","zephyr outputted  %s\n",ret);
 	return ret;
@@ -726,8 +725,7 @@ static char *zephyr_to_html(const char *
 		frames = frames->enclosing;
 		g_free(curr);
 	}
-	ret = frames->text->str;
-	g_string_free(frames->text, FALSE);
+	ret = g_string_free(frames->text, FALSE);
 	g_free(frames);
 	return ret;
 }
