From 63ad19a141f15c0b7af35d35d2b9ea2ac155b931 Mon Sep 17 00:00:00 2001 From: Casey Carter Date: Mon, 14 Aug 2023 19:07:59 -0700 Subject: [PATCH] Don't violate preconditions in tr1/regex3 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 / AB#1854241 --- tests/tr1/tests/regex3/test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/tr1/tests/regex3/test.cpp b/tests/tr1/tests/regex3/test.cpp index d74486aa3cd..1c9c9465cf4 100644 --- a/tests/tr1/tests/regex3/test.cpp +++ b/tests/tr1/tests/regex3/test.cpp @@ -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 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