Skip to content

Commit

Permalink
Don't violate preconditions in tr1/regex3 (#3990)
Browse files Browse the repository at this point in the history
This test constructs a `regex_iterator` and a `regex_token_iterator` with invalid character ranges. The first occurrence is benign - the test never directs the library to examine the bogus part of the range - but the second case ventures into the land of pure undefined behavior. Caught by ASan.

Fixes VSO-1854241
  • Loading branch information
CaseyCarter authored Aug 31, 2023
1 parent 46ca2d7 commit 6c69a73
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/tr1/tests/regex3/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,12 @@ static void test_capturegroups() {
static void test_iterators() { // needs refining after ++ fixed
const CHR* pat = T("ax");
MyIter::regex_type rx(T("a"));
MyIter iter(pat, pat + xlen(pat) + 10, rx);
MyIter iter(pat, pat + xlen(pat), rx);
CHECKSTR(iter->str().c_str(), T("a"));
STD match_results<bidit> mr = *iter;
CHECK_INT(mr.position(0), 0);
CHECK_INT(mr.length(0), 1);
MyTokIter toIter(pat, pat + xlen(pat) + 10, rx);
MyTokIter toIter(pat, pat + xlen(pat), rx);
CHECKSTR(toIter->str().c_str(), T("a"));
toIter++;
#if NO_EXCEPTIONS
Expand Down

0 comments on commit 6c69a73

Please sign in to comment.