changeset 30439:1feb2baeac2d

Fix some media code leaks. Fixes #12349. committer: Elliott Sales de Andrade <qulogic@pidgin.im>
author jakub.adam@ktknet.cz
date Tue, 24 Aug 2010 04:45:25 +0000
parents d91e3a6c4a91
children 6c59e8ad1261
files COPYRIGHT libpurple/media.c libpurple/media/backend-fs2.c libpurple/media/codec.c
diffstat 4 files changed, 13 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/COPYRIGHT	Tue Aug 24 04:42:41 2010 +0000
+++ b/COPYRIGHT	Tue Aug 24 04:45:25 2010 +0000
@@ -18,6 +18,7 @@
 Copyright (C) 1998-2009 by the following:
 
 Saleem Abdulrasool
+Jakub Adam
 Dave Ahlswede
 Manuel Amador
 Matt Amato
--- a/libpurple/media.c	Tue Aug 24 04:42:41 2010 +0000
+++ b/libpurple/media.c	Tue Aug 24 04:45:25 2010 +0000
@@ -515,7 +515,8 @@
 
 	if (!media->priv->sessions) {
 		purple_debug_info("media", "Creating hash table for sessions\n");
-		media->priv->sessions = g_hash_table_new(g_str_hash, g_str_equal);
+		media->priv->sessions = g_hash_table_new_full(g_str_hash, g_str_equal,
+		                                              g_free, NULL);
 	}
 	g_hash_table_insert(media->priv->sessions, g_strdup(session->id), session);
 }
--- a/libpurple/media/backend-fs2.c	Tue Aug 24 04:42:41 2010 +0000
+++ b/libpurple/media/backend-fs2.c	Tue Aug 24 04:45:25 2010 +0000
@@ -208,11 +208,7 @@
 	}
 
 	if (priv->participants) {
-		GList *participants =
-				g_hash_table_get_values(priv->participants);
-		for (; participants; participants = g_list_delete_link(
-				participants, participants))
-			g_object_unref(participants->data);
+		g_hash_table_destroy(priv->participants);
 		priv->participants = NULL;
 	}
 
@@ -1425,7 +1421,8 @@
 	if (!priv->sessions) {
 		purple_debug_info("backend-fs2",
 				"Creating hash table for sessions\n");
-		priv->sessions = g_hash_table_new(g_str_hash, g_str_equal);
+		priv->sessions = g_hash_table_new_full(g_str_hash, g_str_equal,
+		                                       g_free, NULL);
 	}
 
 	g_hash_table_insert(priv->sessions, g_strdup(session->id), session);
@@ -1461,7 +1458,7 @@
 		purple_debug_info("backend-fs2",
 				"Creating hash table for participants\n");
 		priv->participants = g_hash_table_new_full(g_str_hash,
-				g_str_equal, g_free, NULL);
+				g_str_equal, g_free, g_object_unref);
 	}
 
 	g_hash_table_insert(priv->participants, g_strdup(name), participant);
--- a/libpurple/media/codec.c	Tue Aug 24 04:42:41 2010 +0000
+++ b/libpurple/media/codec.c	Tue Aug 24 04:45:25 2010 +0000
@@ -83,9 +83,11 @@
 			PURPLE_MEDIA_CODEC_GET_PRIVATE(info);
 	g_free(priv->encoding_name);
 	for (; priv->optional_params; priv->optional_params =
-			g_list_delete_link(priv->optional_params,
-			priv->optional_params)) {
-		g_free(priv->optional_params->data);
+			g_list_delete_link(priv->optional_params, priv->optional_params)) {
+		PurpleKeyValuePair *param = priv->optional_params->data;
+		g_free(param->key);
+		g_free(param->value);
+		g_free(param);
 	}
 }
 
@@ -302,10 +304,10 @@
 
 	g_free(param->key);
 	g_free(param->value);
-	g_free(param);
 
 	priv->optional_params =
 			g_list_remove(priv->optional_params, param);
+	g_free(param);
 }
 
 PurpleKeyValuePair *