Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Fix invalid read and possible memory leaks
@ 2011-05-27 11:26 Dmitriy Paliy
  2011-05-27 11:56 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitriy Paliy @ 2011-05-27 11:26 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Dmitriy Paliy

Fixed incorrect update of transport->owners GSlist in media_transport_free.
Removal of list entries within 'for' loop leads to invalid read of memory
(l = l->next) and memory leaks.
---
 audio/transport.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/audio/transport.c b/audio/transport.c
index aa3308d..4047d80 100644
--- a/audio/transport.c
+++ b/audio/transport.c
@@ -805,14 +805,21 @@ static GDBusSignalTable transport_signals[] = {
 	{ }
 };
 
+static void media_transport_remove_helper(gpointer data, gpointer user_data)
+{
+	struct media_transport *transport = user_data;
+	struct media_owner *owner = data;
+
+	media_transport_remove(transport, owner);
+}
+
+
 static void media_transport_free(void *data)
 {
 	struct media_transport *transport = data;
-	GSList *l;
-
-	for (l = transport->owners; l; l = l->next)
-		media_transport_remove(transport, l->data);
 
+	g_slist_foreach(transport->owners, media_transport_remove_helper,
+								transport);
 	g_slist_free(transport->owners);
 
 	if (transport->session)
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-05-27 13:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-27 11:26 [PATCH] Fix invalid read and possible memory leaks Dmitriy Paliy
2011-05-27 11:56 ` Luiz Augusto von Dentz
2011-05-27 12:03   ` Dmitriy Paliy
2011-05-27 13:03     ` Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox