]> sourceware.org Git - newlib-cygwin.git/commit
newlib: Fix memory leak regarding gdtoa-based _ldtoa_r().
authorTakashi Yano <takashi.yano@nifty.ne.jp>
Wed, 2 Aug 2023 05:31:53 +0000 (14:31 +0900)
committerTakashi Yano <takashi.yano@nifty.ne.jp>
Wed, 2 Aug 2023 12:59:42 +0000 (21:59 +0900)
commit841b7307d60b4b21418df93190d8134262324eb7
tree11252a21f90569b5fe0d29b72da217b2c816dfcb
parent60ae342e8f22ad2d91eec7278629b9b53a2edded
newlib: Fix memory leak regarding gdtoa-based _ldtoa_r().

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 <natan_b@libero.it>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
newlib/libc/stdlib/gdtoa-dmisc.c
newlib/libc/stdlib/gdtoa-ldtoa.c
winsup/cygwin/release/3.4.8
This page took 0.046048 seconds and 5 git commands to generate.