diff options
-rw-r--r-- | regexec.c | 3 | ||||
-rw-r--r-- | test/ruby/test_regexp.rb | 11 |
2 files changed, 13 insertions, 1 deletions
@@ -4218,7 +4218,8 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, timeout: xfree(xmalloc_base); - xfree(stk_base); + if (stk_base != stk_alloc || IS_NOT_NULL(msa->stack_p)) + xfree(stk_base); HANDLE_REG_TIMEOUT_IN_MATCH_AT; } diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index c996b1785a..03d96954b4 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -1827,6 +1827,17 @@ class TestRegexp < Test::Unit::TestCase end; end + def test_bug_20453 + assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") + begin; + Regexp.timeout = 0.001 + + assert_raise(Regexp::TimeoutError) do + /^(a*)x$/ =~ "a" * 1000000 + "x" + end + end; + end + def per_instance_redos_test(global_timeout, per_instance_timeout, expected_timeout) assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") global_timeout = #{ EnvUtil.apply_timeout_scale(global_timeout).inspect } |