]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix use-after-free in std::format [PR119671]
authorJonathan Wakely <jwakely@redhat.com>
Mon, 7 Apr 2025 18:52:55 +0000 (19:52 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 8 Apr 2025 09:13:39 +0000 (10:13 +0100)
commit059107eb22c4800be94abb1ff9085341cc851432
treeb669431df168f7c95c9ad844e105321b2a46c111
parent7e789f34206f29ae501ddba87faf0e73658a4c5c
libstdc++: Fix use-after-free in std::format [PR119671]

When formatting floating-point values to wide strings there's a case
where we invalidate a std::wstring buffer while a std::wstring_view is
still referring to it.

libstdc++-v3/ChangeLog:

PR libstdc++/119671
* include/std/format (__formatter_fp::format): Do not invalidate
__wstr unless _M_localized returns a valid string.
* testsuite/std/format/functions/format.cc: Check wide string
formatting of floating-point types with classic locale.

Reviewed-by: Tomasz Kaminski <tkaminsk@redhat.com>
(cherry picked from commit e33b62eed7fd0a82d758b23252d288585b6790d2)
libstdc++-v3/include/std/format
libstdc++-v3/testsuite/std/format/functions/format.cc