Skip to content

Commit 988130c

Browse files
author
alexey.lazarev
committed
[libc++][regex] Fix #51028 throw exception in the case of wrong range
1 parent abb8784 commit 988130c

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

libcxx/include/__cxx03/regex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2100,7 +2100,7 @@ public:
21002100
__ranges_.push_back(
21012101
std::make_pair(__traits_.transform(__b.begin(), __b.end()), __traits_.transform(__e.begin(), __e.end())));
21022102
} else {
2103-
if (__b.size() != 1 || __e.size() != 1)
2103+
if (__b.size() != 1 || __e.size() != 1 || __b[0] > __e[0])
21042104
__throw_regex_error<regex_constants::error_range>();
21052105
if (__icase_) {
21062106
__b[0] = __traits_.translate_nocase(__b[0]);

libcxx/include/regex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2120,7 +2120,7 @@ public:
21202120
__ranges_.push_back(
21212121
std::make_pair(__traits_.transform(__b.begin(), __b.end()), __traits_.transform(__e.begin(), __e.end())));
21222122
} else {
2123-
if (__b.size() != 1 || __e.size() != 1)
2123+
if (__b.size() != 1 || __e.size() != 1 || __b[0] > __e[0])
21242124
std::__throw_regex_error<regex_constants::error_range>();
21252125
if (__icase_) {
21262126
__b[0] = __traits_.translate_nocase(__b[0]);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ int main(int, char**)
3333
{
3434
assert(error_range_thrown("([\\w-a])"));
3535
assert(error_range_thrown("([a-\\w])"));
36+
assert(error_range_thrown("([w-a])"));
3637

37-
return 0;
38+
return 0;
3839
}

0 commit comments

Comments
 (0)