Skip to content

Commit

Permalink
Correct stack unwinding inside recursions when seeing (*SKIP).
Browse files Browse the repository at this point in the history
Fixes #152.
  • Loading branch information
jzmaddock committed Oct 20, 2021
1 parent 75600e3 commit 354e02f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/boost/regex/v5/perl_matcher_non_recursive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_startmark()
{
// Must be unwinding from a COMMIT/SKIP/PRUNE and the independent
// sub failed, need to unwind everything else:
while(unwind(false));
while (m_backup_state->state_id)
unwind(false);
return false;
}
#if !defined(BOOST_NO_EXCEPTIONS)
Expand Down
3 changes: 3 additions & 0 deletions test/regress/test_perl_ex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,9 @@ void test_verbs()
TEST_REGEX_SEARCH("AA+(*SKIP)(B|Z)|C", perl, "AAAC", match_default, make_array(3, 4, -1, -1, -2, -2));
TEST_REGEX_SEARCH("AA+(*SKIP)(B|Z)|AC", perl, "AAAC", match_default, make_array(-2, -2));
TEST_REGEX_SEARCH("AA+(*SKIP)B|C", perl, "AAAC", match_default, make_array(3, 4, -2, -2));

// https://github.com/boostorg/regex/issues/152
TEST_REGEX_SEARCH("\\A((\x1f((?1) )?+)?+(*SKIP) *?(?2)*?)\\z", perl, "\x20\x1f\x1f\x20", match_default, make_array(-2, -2));

TEST_REGEX_SEARCH("^(?:aaa(*THEN)\\w{6}|bbb(*THEN)\\w{5}|ccc(*THEN)\\w{4}|\\w{3})", perl, "aaaxxxxxx", match_default, make_array(0, 9, -2, -2));
TEST_REGEX_SEARCH("^(?:aaa(*THEN)\\w{6}|bbb(*THEN)\\w{5}|ccc(*THEN)\\w{4}|\\w{3})", perl, "aaa++++++", match_default, make_array(-2, -2));
Expand Down

0 comments on commit 354e02f

Please sign in to comment.