From 0ac3f2c20e50c22d298238f602f25f84248ac7a5 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 12 Apr 2023 14:54:26 +0900 Subject: [Bug #19587] Fix `reset_match_cache` arguments --- regexec.c | 2 +- test/ruby/test_regexp.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/regexec.c b/regexec.c index 2fb5af757f..65f8e8ee44 100644 --- a/regexec.c +++ b/regexec.c @@ -3480,7 +3480,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, default: goto unexpected_bytecode_error; } - reset_match_cache(reg, addr, pbegin, (long)(s - str), msa->match_cache, msa->cache_index_table, msa->num_cache_table ,msa->num_cache_opcode); + reset_match_cache(reg, addr, pbegin, (long)(s - str), msa->match_cache, msa->cache_index_table, msa->num_cache_opcode, msa->num_cache_table); } # endif } diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 81dac20648..6ec77a41a3 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -1750,6 +1750,14 @@ class TestRegexp < Test::Unit::TestCase end; end + def test_cache_index_initialize + str = 'test1-test2-test3-test4-test_5' + re = '^([0-9a-zA-Z\-/]*){1,256}$' + 100.times do + assert !Regexp.new(re).match?(str) + end + end + def test_bug_19273 # [Bug #19273] pattern = /(?:(?:-?b)|(?:-?(?:1_?(?:0_?)*)?0))(?::(?:(?:-?b)|(?:-?(?:1_?(?:0_?)*)?0))){0,3}/ assert_equal("10:0:0".match(pattern)[0], "10:0:0") -- cgit v1.2.1