2012-08-24 23:51:38

by Vinicius Costa Gomes

[permalink] [raw]
Subject: [PATCH BlueZ] core: Fix memory leak

When ignoring a LE device that is not in a discoverable state 'alias'
is leaking.
---
src/adapter.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/adapter.c b/src/adapter.c
index b642e37..532fcdd 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2707,8 +2707,10 @@ void adapter_emit_device_found(struct btd_adapter *adapter,

/* Avoid emitting DeviceFound() signal if device is not
* discoverable */
- if (!(dev->flags & (EIR_LIM_DISC | EIR_GEN_DISC)))
+ if (!(dev->flags & (EIR_LIM_DISC | EIR_GEN_DISC))) {
+ g_free(alias);
return;
+ }

dev->legacy = FALSE;

--
1.7.12



2012-08-26 07:30:22

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH BlueZ] core: Fix memory leak

Hi Vinicius,

On Fri, Aug 24, 2012, Vinicius Costa Gomes wrote:
> When ignoring a LE device that is not in a discoverable state 'alias'
> is leaking.
> ---
> src/adapter.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)

Applied. Thanks.

Johan

2012-10-26 08:01:42

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH BlueZ] core: Fix memory leak

Hi Luiz,

On Fri, Oct 26, 2012, Luiz Augusto von Dentz wrote:
> 1,262 (64 direct, 1,198 indirect) bytes in 1 blocks are definitely lost in loss record 280 of 290
> at 0x4A0881C: malloc (vg_replace_malloc.c:270)
> by 0x4C813FE: g_malloc (in /usr/lib64/libglib-2.0.so.0.3200.4)
> by 0x4C95801: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.3200.4)
> by 0x4C95D55: g_slice_alloc0 (in /usr/lib64/libglib-2.0.so.0.3200.4)
> by 0x4C746AA: g_key_file_new (in /usr/lib64/libglib-2.0.so.0.3200.4)
> by 0x18136C: load_config (adapter.c:2620)
> by 0x18353B: adapter_init (adapter.c:2708)
> by 0x17E62E: btd_manager_register_adapter (manager.c:337)
> by 0x191171: mgmt_event.part.36 (mgmt.c:1081)
> by 0x4C7B824: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3200.4)
> by 0x4C7BB57: ??? (in /usr/lib64/libglib-2.0.so.0.3200.4)
> by 0x4C7BF51: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3200.4)
> ---
> src/adapter.c | 2 ++
> 1 file changed, 2 insertions(+)

Applied. Thanks.

Johan