summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorHugo van der Sanden <hv@crypt.org>2020-04-18 14:43:02 +0100
committerHugo van der Sanden <hv@crypt.org>2020-04-23 11:10:09 +0100
commit089ad25d3f4e8c7f5ff9b3a80e2e1dfa50f1a634 (patch)
treece8928b50a37217d0524e8baa9c82dc9f2c2b2a4 /t
parent3b53f4ea6ed5cc4af123b84b376cd30e2722f303 (diff)
downloadperl-089ad25d3f4e8c7f5ff9b3a80e2e1dfa50f1a634.tar.gz
gh16947: avoid mutating regexp program only within GOSUB
Commits 3bc2a7809d and bdb91f3f96 used the existence of a frame to decide when it was unsafe to mutate the regexp program, due to having recursed for as GOSUB. However the frame recursion mechanism is also used for SUSPEND. Refine it further to avoid mutation only when within a GOSUB by saving a new boolean in the frame structure, and using that to derive a "mutate_ok" flag.
Diffstat (limited to 't')
-rw-r--r--t/re/pat.t11
1 files changed, 8 insertions, 3 deletions
diff --git a/t/re/pat.t b/t/re/pat.t
index 5a6e1daaf0..455132085c 100644
--- a/t/re/pat.t
+++ b/t/re/pat.t
@@ -24,7 +24,7 @@ BEGIN {
skip_all_without_unicode_tables();
-plan tests => 1018; # Update this when adding/deleting tests.
+plan tests => 1019; # Update this when adding/deleting tests.
run_tests() unless caller;
@@ -2252,11 +2252,16 @@ SKIP:
ok($result, "regexp correctly matched");
}
- # gh16947: test regexp corruption
+ # gh16947: test regexp corruption (GOSUB)
{
fresh_perl_is(q{
'xy' =~ /x(?0)|x(?|y|y)/ && print 'ok'
- }, 'ok', {}, 'gh16947: test regexp corruption');
+ }, 'ok', {}, 'gh16947: test regexp corruption (GOSUB)');
+ }
+ # gh16947: test fix doesn't break SUSPEND
+ {
+ fresh_perl_is(q{ 'sx' =~ m{ss++}i; print 'ok' },
+ 'ok', {}, "gh16947: test fix doesn't break SUSPEND");
}
} # End of sub run_tests