Permalink
Browse files

The stack may be reallocated in the func call; fix #3560

  • Loading branch information...
matz committed Apr 1, 2017
1 parent 8d9d7c9 commit 1e87dfdf48e3870ed10cd6ad071bc29e6e3dc636
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/vm.c
View
@@ -1449,13 +1449,16 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
mrb->c->stack[0] = recv;
if (MRB_PROC_CFUNC_P(m)) {
mrb_value v;
if (n == CALL_MAXARGS) {
ci->nregs = 3;
}
else {
ci->nregs = n + 2;
}
mrb->c->stack[0] = m->body.func(mrb, recv);
v = m->body.func(mrb, recv);
mrb->c->stack[0] = v;
mrb_gc_arena_restore(mrb, ai);
if (mrb->exc) goto L_RAISE;
/* pop stackpos */
@@ -1862,7 +1865,8 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
value_move(mrb->c->stack, &regs[a], ci->argc+1);
if (MRB_PROC_CFUNC_P(m)) {
mrb->c->stack[0] = m->body.func(mrb, recv);
mrb_value v = m->body.func(mrb, recv);
mrb->c->stack[0] = v;
mrb_gc_arena_restore(mrb, ai);
goto L_RETURN;
}

0 comments on commit 1e87dfd

Please sign in to comment.