зеркало из https://github.com/github/ruby.git
Fix next inside block argument stack underflow
[Bug #20344] Fix compile_next adding removable adjust label
This commit is contained in:
Родитель
2a7da0b6e7
Коммит
992596fb7a
|
@ -3070,8 +3070,7 @@ remove_unreachable_chunk(rb_iseq_t *iseq, LINK_ELEMENT *i)
|
|||
/* do nothing */
|
||||
}
|
||||
else if (IS_ADJUST(i)) {
|
||||
LABEL *dest = ((ADJUST *)i)->label;
|
||||
if (dest && dest->unremovable) return 0;
|
||||
return 0;
|
||||
}
|
||||
end = i;
|
||||
} while ((i = i->next) != 0);
|
||||
|
@ -8205,7 +8204,6 @@ compile_next(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
|
|||
add_ensure_iseq(ret, iseq, 0);
|
||||
ADD_INSNL(ret, line_node, jump, ISEQ_COMPILE_DATA(iseq)->end_label);
|
||||
ADD_ADJUST_RESTORE(ret, splabel);
|
||||
splabel->unremovable = FALSE;
|
||||
|
||||
if (!popped) {
|
||||
ADD_INSN(ret, line_node, putnil);
|
||||
|
|
|
@ -828,6 +828,27 @@ class TestISeq < Test::Unit::TestCase
|
|||
end;
|
||||
end
|
||||
|
||||
def test_unreachable_next_in_block
|
||||
bug20344 = '[ruby-core:117210] [Bug #20344]'
|
||||
assert_nothing_raised(SyntaxError, bug20344) do
|
||||
compile(<<~RUBY)
|
||||
proc do
|
||||
next
|
||||
|
||||
case nil
|
||||
when "a"
|
||||
next
|
||||
when "b"
|
||||
when "c"
|
||||
proc {}
|
||||
end
|
||||
|
||||
next
|
||||
end
|
||||
RUBY
|
||||
end
|
||||
end
|
||||
|
||||
def test_loading_kwargs_memory_leak
|
||||
assert_no_memory_leak([], "#{<<~"begin;"}", "#{<<~'end;'}", rss: true)
|
||||
a = RubyVM::InstructionSequence.compile("foo(bar: :baz)").to_binary
|
||||
|
|
Загрузка…
Ссылка в новой задаче