Skip to content

Commit d7c42f1

Browse files
committed
[regex] fix uncaught exception when string is like "\\_"
fixes #129062
1 parent a955426 commit d7c42f1

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

libcxx/include/regex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3954,7 +3954,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_escape(
39543954
++__first;
39553955
break;
39563956
default:
3957-
if (*__first != '_' && !__traits_.isctype(*__first, ctype_base::alnum)) {
3957+
if (!__traits_.isctype(*__first, ctype_base::alnum)) {
39583958
if (__str)
39593959
*__str = *__first;
39603960
else

libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,12 @@ int main(int, char**)
13051305
assert(m.position(0) == 0);
13061306
assert(m.str(0) == s);
13071307
}
1308+
{
1309+
std::cmatch m;
1310+
const char s[] = "$_se";
1311+
assert(std::regex_match(s, m, std::regex("\\$\\_se")));
1312+
assert(m.size() == 1);
1313+
}
13081314
#endif // TEST_HAS_NO_WIDE_CHARACTERS
13091315

13101316
return 0;

libcxx/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ int main(int, char**)
3232
test("\\(a\\([bc]\\)\\)", 0);
3333
test("(a([bc]))", 2);
3434

35-
return 0;
35+
return 0;
3636
}

0 commit comments

Comments
 (0)