From b726d60c986bf951d13e7a2ab5f5e58f58657b03 Mon Sep 17 00:00:00 2001 From: TSUYUSATO Kitsune Date: Wed, 28 Dec 2022 20:03:25 +0900 Subject: [PATCH] Fix [Bug 19273], set correct value to `outer_repeat` on `OP_REPEAT` (#7035) --- regexec.c | 2 +- test/ruby/test_regexp.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/regexec.c b/regexec.c index c95abad258..d261a3cbc0 100644 --- a/regexec.c +++ b/regexec.c @@ -615,7 +615,7 @@ init_cache_index_table(regex_t* reg, OnigCacheIndex *table) if (reg->repeat_range[mem].lower == 0) { table->addr = pbegin; table->num = num - current_mem_num; - table->outer_repeat = mem; + table->outer_repeat = -1; num++; table++; } diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 40d3559c0b..98bf41d2f1 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -1721,6 +1721,11 @@ class TestRegexp < Test::Unit::TestCase 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") + end + def test_linear_time_p assert_send [Regexp, :linear_time?, /a/] assert_send [Regexp, :linear_time?, 'a']