8000 Fix to work match cache with peek next optimization (#9459) · ruby/ruby@597955a · GitHub
[go: up one dir, main page]

Skip to content

Commit 597955a

Browse files
authored
Fix to work match cache with peek next optimization (#9459)
1 parent 1817d64 commit 597955a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

regexec.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3758,14 +3758,15 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
37583758

37593759
CASE(OP_PUSH_IF_PEEK_NEXT) MOP_IN(OP_PUSH_IF_PEEK_NEXT);
37603760
GET_RELADDR_INC(addr, p);
3761+
CHECK_MATCH_CACHE;
37613762
if (*p == *s) {
37623763
p++;
3763-
CHECK_MATCH_CACHE;
37643764
STACK_PUSH_ALT(p + addr, s, sprev, pkeep);
37653765
MOP_OUT;
37663766
JUMP;
37673767
}
37683768
p++;
3769+
INC_NUM_FAILS;
37693770
MOP_OUT;
37703771
JUMP;
37713772

test/ruby/test_regexp.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,6 +1945,15 @@ def test_match_cache_negative_look_behind
19451945
end;
19461946
end
19471947

1948+
def test_match_cache_with_peek_optimization
1949+
assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}")
1950+
timeout = #{ EnvUtil.apply_timeout_scale(10).inspect }
1951+
begin;
1952+
Regexp.timeout = timeout
1953+
assert_nil(/a*z/ =~ "a" * 1000000 + "x")
1954+
end;
1955+
end
1956+
19481957
def test_cache_opcodes_initialize
19491958
str = 'test1-test2-test3-test4-test_5'
19501959
re = '^([0-9a-zA-Z\-/]*){1,256}$'

0 commit comments

Comments
 (0)
0