* [PATCH v3] malloc: fix memleak in function muntrace
@ 2020-04-21 11:48 chenzefeng
2020-04-22 12:39 ` Florian Weimer
0 siblings, 1 reply; 3+ messages in thread
From: chenzefeng @ 2020-04-21 11:48 UTC (permalink / raw)
To: libc-alpha, fw, dj, zackw; +Cc: liucheng32, chenzefeng2, zengweilin
when we call functons as follow:
mtrace();
...
muntrace();
It would cause memleak, for the mtrace malloc some memory:
mtd = malloc(TRACE_BUFFER_SIZE);
and it would not be free. Therefor it should be freed in muntrace.
Signed-off-by: chenzefeng <chenzefeng2@huawei.com>
---
malloc/mtrace.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/malloc/mtrace.c b/malloc/mtrace.c
index 7e7719df97..5d7bc62857 100644
--- a/malloc/mtrace.c
+++ b/malloc/mtrace.c
@@ -365,4 +365,6 @@ muntrace (void)
fprintf (f, "= End\n");
fclose (f);
+ free (malloc_trace_buffer);
+ malloc_trace_buffer == NULL;
}
--
2.12.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] malloc: fix memleak in function muntrace
2020-04-21 11:48 [PATCH v3] malloc: fix memleak in function muntrace chenzefeng
@ 2020-04-22 12:39 ` Florian Weimer
2020-04-24 1:24 ` chenzefeng (A)
0 siblings, 1 reply; 3+ messages in thread
From: Florian Weimer @ 2020-04-22 12:39 UTC (permalink / raw)
To: chenzefeng; +Cc: libc-alpha, dj, zackw, liucheng32, zengweilin
* chenzefeng:
> when we call functons as follow:
> mtrace();
> ...
> muntrace();
> It would cause memleak, for the mtrace malloc some memory:
> mtd = malloc(TRACE_BUFFER_SIZE);
> and it would not be free. Therefor it should be freed in muntrace.
>
> Signed-off-by: chenzefeng <chenzefeng2@huawei.com>
Same question as before:
glibc uses copyright assignment to the FSF for contributions, and not
the DCO.
I trust this contribution is covered by Huawei's copyright assignment?
> ---
> malloc/mtrace.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/malloc/mtrace.c b/malloc/mtrace.c
> index 7e7719df97..5d7bc62857 100644
> --- a/malloc/mtrace.c
> +++ b/malloc/mtrace.c
> @@ -365,4 +365,6 @@ muntrace (void)
>
> fprintf (f, "= End\n");
> fclose (f);
> + free (malloc_trace_buffer);
> + malloc_trace_buffer == NULL;
> }
Please test your patches before you post them:
mtrace.c: In function ‘muntrace’:
mtrace.c:369:23: error: statement with no effect [-Werror=unused-value]
malloc_trace_buffer == NULL;
^
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH v3] malloc: fix memleak in function muntrace
2020-04-22 12:39 ` Florian Weimer
@ 2020-04-24 1:24 ` chenzefeng (A)
0 siblings, 0 replies; 3+ messages in thread
From: chenzefeng (A) @ 2020-04-24 1:24 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha, dj, zackw, liucheng (G), Zengweilin
* Florian Weimer:
>* chenzefeng:
>> when we call functons as follow:
>> mtrace();
>> ...
>> muntrace();
> >It would cause memleak, for the mtrace malloc some memory:
>> mtd = malloc(TRACE_BUFFER_SIZE);
> >and it would not be free. Therefor it should be freed in muntrace.
>>
> >Signed-off-by: chenzefeng <chenzefeng2@huawei.com>
>Same question as before:
>glibc uses copyright assignment to the FSF for contributions, and not the DCO.
>I trust this contribution is covered by Huawei's copyright assignment?
Yet, this patch uses copyright assignment to the FSF for contributions.
>> ---
>> malloc/mtrace.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/malloc/mtrace.c b/malloc/mtrace.c index
>> 7e7719df97..5d7bc62857 100644
>> --- a/malloc/mtrace.c
>> +++ b/malloc/mtrace.c
>> @@ -365,4 +365,6 @@ muntrace (void)
>>
>> fprintf (f, "= End\n");
>> fclose (f);
>>+ free (malloc_trace_buffer);
>> + malloc_trace_buffer == NULL;
>> }
>Please test your patches before you post them:
>mtrace.c: In function ‘muntrace’:
>mtrace.c:369:23: error: statement with no effect [-Werror=unused-value]
> malloc_trace_buffer == NULL;
Fix it in patch v4
^
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-04-24 1:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-21 11:48 [PATCH v3] malloc: fix memleak in function muntrace chenzefeng
2020-04-22 12:39 ` Florian Weimer
2020-04-24 1:24 ` chenzefeng (A)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).