Skip to content

Commit dfd5830

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

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
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;

0 commit comments

Comments
 (0)