2011-05-27 13:33:50

by Dmitriy Paliy

[permalink] [raw]
Subject: [PATCH v2 0/1] Fix invalid read and possible memory leaks

Hi,

This is updated version that takes into account comments of Luiz.

Thanks for the feedback,
Dmitriy



2011-05-29 19:11:50

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH v2] Fix invalid read and possible memory leaks

Hi Dmitriy,

On Fri, May 27, 2011, Dmitriy Paliy wrote:
> 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 files changed, 6 insertions(+), 3 deletions(-)

Applied. Thanks.

Johan

2011-05-27 13:33:51

by Dmitriy Paliy

[permalink] [raw]
Subject: [PATCH v2] 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 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/audio/transport.c b/audio/transport.c
index aa3308d..7c99207 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);

--
1.7.4.1