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++/84110] Null character in regex throws std::regex_error Date: Thu, 07 Jul 2022 23:32:15 +0000 [thread overview] Message-ID: <bug-84110-4-1ARk5dnFi4@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-84110-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84110 --- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>: https://gcc.gnu.org/g:5df21c00aedb7878b8854901e95d7eda70266d31 commit r11-10118-g5df21c00aedb7878b8854901e95d7eda70266d31 Author: Jonathan Wakely <jwakely@redhat.com> Date: Wed Sep 29 13:48:11 2021 +0100 libstdc++: std::basic_regex should treat '\0' as an ordinary char [PR84110] When the input sequence contains a _CharT(0) character, the strchr call in _Scanner<_CharT>::_M_scan_normal() will search for '\0' and so return a pointer to the terminating null at the end of the string. This makes the scanner think it's found a special character. Because it doesn't match any of the actual special characters, we fall off the end of the function (or assert in debug mode). We should check for a null character explicitly and either treat it as an ordinary character (for the ECMAScript grammar) or an error (for all others). I'm not 100% sure that's right, but it seems consistent with the POSIX RE rules where a '\0' means the end of the regex pattern or the end of the sequence being matched. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/84110 * include/bits/regex_error.h (regex_constants::_S_null): New error code for internal use. * include/bits/regex_scanner.tcc (_Scanner::_M_scan_normal()): Check for null character. * testsuite/28_regex/basic_regex/84110.cc: New test. (cherry picked from commit b701e1f8f6870c0f8cb4050674da489101dd05a5)
next prev parent reply other threads:[~2022-07-07 23:32 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-84110-4@http.gcc.gnu.org/bugzilla/> 2021-09-22 10:17 ` redi at gcc dot gnu.org 2021-09-24 20:40 ` redi at gcc dot gnu.org 2021-09-25 10:43 ` redi at gcc dot gnu.org 2021-09-29 12:49 ` cvs-commit at gcc dot gnu.org 2021-09-29 15:48 ` redi at gcc dot gnu.org 2022-07-07 23:32 ` cvs-commit at gcc dot gnu.org [this message] 2022-07-07 23:35 ` redi at gcc dot gnu.org 2023-06-23 16:12 ` cvs-commit at gcc dot gnu.org 2023-06-23 16:17 ` 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-84110-4-1ARk5dnFi4@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).