]> git.ipfire.org Git - thirdparty/glibc.git/commit
stdio: Remove memory leak from multibyte convertion [BZ#25691]
authorFlorian Weimer <fweimer@redhat.com>
Thu, 19 Mar 2020 21:32:28 +0000 (18:32 -0300)
committerFlorian Weimer <fweimer@redhat.com>
Tue, 30 Aug 2022 08:36:09 +0000 (10:36 +0200)
commit2adadce76d48ca87cd6edb5416c01381555d7d94
treec442dd28ab4f24e55ecc97ae88cf76e84a7a55d8
parenta79bc55e5be07d797d77b63fc0018eb515ae7049
stdio: Remove memory leak from multibyte convertion [BZ#25691]

This is an updated version of a previous patch [1] with the
following changes:

  - Use compiler overflow builtins on done_add_func function.
  - Define the scratch +utstring_converted_wide_string using
    CHAR_T.
  - Added a testcase and mention the bug report.

Both default and wide printf functions might leak memory when
manipulate multibyte characters conversion depending of the size
of the input (whether __libc_use_alloca trigger or not the fallback
heap allocation).

This patch fixes it by removing the extra memory allocation on
string formatting with conversion parts.

The testcase uses input argument size that trigger memory leaks
on unpatched code (using a scratch buffer the threashold to use
heap allocation is lower).

Checked on x86_64-linux-gnu and i686-linux-gnu.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
[1] https://sourceware.org/pipermail/libc-alpha/2017-June/082098.html

(cherry picked from commit 3cc4a8367c23582b7db14cf4e150e4068b7fd461)
NEWS
stdio-common/vfprintf-internal.c