]> 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 07:43:22 +0000 (08:43 +0100)
commite33b62eed7fd0a82d758b23252d288585b6790d2
tree5685df95e7322abee9a2054b7706f4a66e9c6d29
parenta9bbb60b7ca7bf83c0e8657c61867e3786091916
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>
libstdc++-v3/include/std/format
libstdc++-v3/testsuite/std/format/functions/format.cc