Skip to content

Commit 3bc2a78

Browse files
hvdskhwilliamson
authored andcommitted
study_chunk: do not rewrite for trie while enframed
gh16947: the outer frame may be in the middle of looking at the part of the program we would rewrite. Let the outer frame deal with it.
1 parent 8f8f6a1 commit 3bc2a78

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

regcomp.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4804,9 +4804,10 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp,
48044804
}
48054805
}
48064806

4807-
if (PERL_ENABLE_TRIE_OPTIMISATION &&
4808-
OP( startbranch ) == BRANCH )
4809-
{
4807+
if (PERL_ENABLE_TRIE_OPTIMISATION
4808+
&& OP(startbranch) == BRANCH
4809+
&& !frame
4810+
) {
48104811
/* demq.
48114812

48124813
Assuming this was/is a branch we are dealing with: 'scan'

t/re/pat.t

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ BEGIN {
2424

2525
skip_all_without_unicode_tables();
2626

27-
plan tests => 1017; # Update this when adding/deleting tests.
27+
plan tests => 1018; # Update this when adding/deleting tests.
2828

2929
run_tests() unless caller;
3030

@@ -2252,6 +2252,13 @@ SKIP:
22522252
ok($result, "regexp correctly matched");
22532253
}
22542254

2255+
# gh16947: test regexp corruption
2256+
{
2257+
fresh_perl_is(q{
2258+
'xy' =~ /x(?0)|x(?|y|y)/ && print 'ok'
2259+
}, 'ok', {}, 'gh16947: test regexp corruption');
2260+
}
2261+
22552262
} # End of sub run_tests
22562263

22572264
1;

0 commit comments

Comments
 (0)