Permalink
Browse files

VM stack may be reallocated in `mrb_convert_type()`; fix #3622

  • Loading branch information...
matz committed Apr 21, 2017
1 parent 262fbaf commit 94bcdca64fb08e3724c1a5cf6ce25f6f9c6e041e
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/vm.c
View
@@ -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);
@@ -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 */

0 comments on commit 94bcdca

Please sign in to comment.