public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/103664] std::regex_replace bug if the string contains \0 Date: Fri, 23 Jun 2023 16:12:33 +0000 [thread overview] Message-ID: <bug-103664-4-apL6dGsqno@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-103664-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103664 --- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-10 branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>: https://gcc.gnu.org/g:364cb498c472790e14561f7672dc5ab4a9222287 commit r10-11462-g364cb498c472790e14561f7672dc5ab4a9222287 Author: Jonathan Wakely <jwakely@redhat.com> Date: Sun Dec 12 21:15:17 2021 +0000 libstdc++: Fix std::regex_replace for strings with embedded null [PR103664] The overload of std::regex_replace that takes a std::basic_string as the fmt argument (for the replacement string) is implemented in terms of the one taking a const C*, which uses std::char_traits to find the length. That means it stops at a null character, even though the basic_string might have additional characters beyond that. Rather than duplicate the implementation of the const C* one for the std::basic_string case, this moves that implementation to a new __regex_replace function which takes a const C* and a length. Then both the std::basic_string and const C* overloads can call that (with the latter using char_traits to find the length to pass to the new function). libstdc++-v3/ChangeLog: PR libstdc++/103664 * include/bits/regex.h (__regex_replace): Declare. (regex_replace): Use it. * include/bits/regex.tcc (__regex_replace): Replace regex_replace definition with __regex_replace. * testsuite/28_regex/algorithms/regex_replace/char/103664.cc: New test. (cherry picked from commit ef5d671cd80a4afa4f74c3dfe2904c63f51fcfde)
next prev parent reply other threads:[~2023-06-23 16:12 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-12-11 21:52 [Bug libstdc++/103664] New: " artur77 at freemail dot hu 2021-12-12 2:39 ` [Bug libstdc++/103664] " pinskia at gcc dot gnu.org 2021-12-12 12:26 ` redi at gcc dot gnu.org 2021-12-12 12:34 ` redi at gcc dot gnu.org 2021-12-13 11:16 ` cvs-commit at gcc dot gnu.org 2021-12-13 11:50 ` redi at gcc dot gnu.org 2022-07-07 23:32 ` cvs-commit at gcc dot gnu.org 2023-06-09 9:47 ` redi at gcc dot gnu.org 2023-06-23 16:12 ` cvs-commit at gcc dot gnu.org [this message] 2023-06-23 16:18 ` redi at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-103664-4-apL6dGsqno@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).