Skip to content

Commit

Permalink
Extend VM stack just in case; ref #3551
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Apr 1, 2017
1 parent 071164b commit 93d8029
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1202,8 +1202,10 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
else {
mrb_value blk = regs[bidx];
if (!mrb_nil_p(blk) && mrb_type(blk) != MRB_TT_PROC) {
if(bidx >= mrb->c->ci->nregs)
if(bidx >= mrb->c->ci->nregs) {
stack_extend(mrb, bidx+1, mrb->c->ci->nregs);
mrb->c->ci->nregs = bidx+1;
}
regs[bidx] = mrb_convert_type(mrb, blk, MRB_TT_PROC, "Proc", "to_proc");
}
}
Expand Down Expand Up @@ -1439,8 +1441,10 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
}
blk = regs[bidx];
if (!mrb_nil_p(blk) && mrb_type(blk) != MRB_TT_PROC) {
if(bidx >= ci->nregs)
if(bidx >= ci->nregs) {
stack_extend(mrb, bidx+1, ci->nregs);
ci->nregs = bidx+1;
}
regs[bidx] = mrb_convert_type(mrb, blk, MRB_TT_PROC, "Proc", "to_proc");
ci = mrb->c->ci;
}
Expand Down

0 comments on commit 93d8029

Please sign in to comment.