/cpw/tomkiewicz/http: fb792f8b6265: Fix leak caused by my previo...

Tomasz Wasilczyk tomkiewicz at cpw.pidgin.im
Sun Oct 14 02:37:56 EDT 2012


Changeset: fb792f8b626540f4ce87fc5f559470d20c75a89a
Author:	 Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date:	 2012-10-14 08:37 +0200
Branch:	 default
URL: http://hg.pidgin.im/cpw/tomkiewicz/http/rev/fb792f8b6265

Description:

Fix leak caused by my previous temporary fix

diffstat:

 libpurple/http.c |  12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diffs (36 lines):

diff --git a/libpurple/http.c b/libpurple/http.c
--- a/libpurple/http.c
+++ b/libpurple/http.c
@@ -129,9 +129,8 @@ static PurpleHttpHeaders * purple_http_h
 {
 	PurpleHttpHeaders *hdrs = g_new0(PurpleHttpHeaders, 1);
 
-	hdrs->by_name = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
-//	hdrs->by_name = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
-//		(GDestroyNotify)g_list_free);
+	hdrs->by_name = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
+		(GDestroyNotify)g_list_free);
 
 	return hdrs;
 }
@@ -158,7 +157,7 @@ static void purple_http_headers_add(Purp
 	const gchar *value)
 {
 	PurpleKeyValuePair *kvp;
-	GList *named_values;
+	GList *named_values, *new_values;
 
 	g_return_if_fail(hdrs != NULL);
 	g_return_if_fail(key != NULL);
@@ -171,8 +170,9 @@ static void purple_http_headers_add(Purp
 	hdrs->list = g_list_append(hdrs->list, kvp);
 
 	named_values = g_hash_table_lookup(hdrs->by_name, key);
-	named_values = g_list_append(named_values, kvp->value);
-	g_hash_table_replace(hdrs->by_name, g_strdup(key), named_values);
+	new_values = g_list_append(named_values, kvp->value);
+	if (!named_values)
+		g_hash_table_insert(hdrs->by_name, g_strdup(key), new_values);
 }
 
 static const GList * purple_http_headers_get_all(PurpleHttpHeaders *hdrs)



More information about the Commits mailing list