From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5E9003858D32; Thu, 10 Aug 2023 13:19:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5E9003858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691673589; bh=nJc5Gr7+8miKarCxNCZk0IDJjoU7L96/BQGOzU56SmA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jnZ7V0mf4BI4C0hjQLYqDnFZk1TBQLx3KUa2IcjcehwvFyrkuGqQ110pP46GXe4RT b9zh85WWmsrlzRF5uR0ANBpDfHWgHl77FTU1046w++KfMRnZT0Ako+QLq3Djgw0QJi wbhYerv0qAW9hlJlqRne81/v7/rQl3RgBEgWFu54= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/110968] format out of bounds read on format("{:05L}",-1.f) Date: Thu, 10 Aug 2023 13:19:49 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 13.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: redi at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110968 --- Comment #2 from Jonathan Wakely --- --- a/libstdc++-v3/include/std/format +++ b/libstdc++-v3/include/std/format @@ -1634,7 +1634,8 @@ namespace __format __wstr =3D _M_localize(__str, __expc, __fc.locale()); else __wstr =3D _M_localize(__str, __expc, __loc.value()); - __str =3D __wstr; + if (!__wstr.empty()) + __str =3D __wstr; } size_t __width =3D _M_spec._M_get_width(__fc);=