Re: [PATCH v2] newlib: Fix memory leak regarding gdtoa-based _ldtoa_r().
Corinna Vinschen <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
Hi Takashi,
On Aug 2 15:37, Takashi Yano wrote:
> After the commit a4705d387f78, printf() for floating-point values
> causes a memory leak. The legacy _ldtoa_r() assumed the char pointer
> returned will be free'ed by Bfree(). However, gdtoa-based _ldtoa_r()
> returns the pointer returned by gdtoa() which should be free'ed by
> freedtoa(). Due to this issue, the caller of _ldtoa_r() fails to free
> the allocated char buffer. This is the cause of the said memory leak.
> https://cygwin.com/pipermail/cygwin/2023-July/254054.html
>
> This patch makes rv_alloc()/freedtoa() allocate/free the buffer in
> a compatible way with legacy _ldtoa_r().
>
> Fixes: a4705d387f78 ("ldtoa: Import gdtoa from OpenBSD.")
> Reported-by: natan_b <[email protected]>
> Reviewed-by: Corinna Vinschen <[email protected]>
> Signed-off-by: Takashi Yano <[email protected]>
> ---
> newlib/libc/stdlib/gdtoa-dmisc.c | 23 +++++++++++++----------
> newlib/libc/stdlib/gdtoa-ldtoa.c | 4 +---
> winsup/cygwin/release/3.4.8 | 3 +++
> 3 files changed, 17 insertions(+), 13 deletions(-)
looks good to me, please push.
Thanks,
Corinna