Skip to content

Commit

Permalink
VM stack may be reallocated in mrb_convert_type(); fix #3622
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Apr 21, 2017
1 parent 262fbaf commit 94bcdca
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 @@ -1244,7 +1244,8 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
stack_extend(mrb, bidx+1);
mrb->c->ci->nregs = bidx+1;
}
regs[bidx] = mrb_convert_type(mrb, blk, MRB_TT_PROC, "Proc", "to_proc");
result = mrb_convert_type(mrb, blk, MRB_TT_PROC, "Proc", "to_proc");
regs[bidx] = result;
}
}
c = mrb_class(mrb, recv);
Expand Down Expand Up @@ -1468,11 +1469,14 @@ 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) {
mrb_value result;

if (bidx >= ci->nregs) {
stack_extend(mrb, bidx+1);
ci->nregs = bidx+1;
}
regs[bidx] = mrb_convert_type(mrb, blk, MRB_TT_PROC, "Proc", "to_proc");
result = mrb_convert_type(mrb, blk, MRB_TT_PROC, "Proc", "to_proc");
regs[bidx] = result;
}

/* push callinfo */
Expand Down

0 comments on commit 94bcdca

Please sign in to comment.