Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions regexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -4217,9 +4217,8 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
return ONIGERR_UNEXPECTED_BYTECODE;

timeout:
STACK_SAVE;
xfree(xmalloc_base);
if (stk_base != stk_alloc || IS_NOT_NULL(msa->stack_p))
xfree(stk_base);
return ONIGERR_TIMEOUT;
}

Expand Down
7 changes: 7 additions & 0 deletions test/ruby/test_regexp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1838,6 +1838,13 @@ def test_bug_20453
end;
end

def test_bug_20886
re = Regexp.new("d()*+|a*a*bc", timeout: 0.02)
assert_raise(Regexp::TimeoutError) do
re === "b" + "a" * 1000
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 }
Expand Down
Loading