From a740e8599e9e529ffc6ef621e763160edae2858d Mon Sep 17 00:00:00 2001 From: Dmitriy Paliy Date: Fri, 27 May 2011 16:33:51 +0300 Subject: [PATCH] Fix invalid read and possible memory leaks 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 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/audio/transport.c b/audio/transport.c index aa3308db7..7c99207a3 100644 --- a/audio/transport.c +++ b/audio/transport.c @@ -808,10 +808,13 @@ static GDBusSignalTable transport_signals[] = { static void media_transport_free(void *data) { struct media_transport *transport = data; - GSList *l; + GSList *l = transport->owners; - for (l = transport->owners; l; l = l->next) - media_transport_remove(transport, l->data); + while (l) { + struct media_owner *owner = l->data; + l = l->next; + media_transport_remove(transport, owner); + } g_slist_free(transport->owners); -- 2.47.3