Skip to content

Commit

Permalink
Clear VM stack for top level; fix #3676
Browse files Browse the repository at this point in the history
Top-level local variables contained junk after ab25eae
  • Loading branch information
matz committed May 30, 2017
1 parent ef11584 commit 2599c19
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -851,13 +851,19 @@ mrb_vm_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stac
mrb_value result;
struct mrb_context *c = mrb->c;
int cioff = c->ci - c->cibase;
int nregs = irep->nregs;
mrb_value *stk;

if (!c->stack) {
stack_init(mrb);
}
if (stack_keep < irep->nregs)
stack_keep = irep->nregs;
stack_extend(mrb, stack_keep);
if (stack_keep > nregs)
nregs = stack_keep;
stk = c->stack + stack_keep;
if (stk < c->stend) {
stack_clear(stk, c->stend - stk);
}
stack_extend(mrb, nregs);
c->stack[0] = self;
result = mrb_vm_exec(mrb, proc, irep->iseq);
if (c->ci - c->cibase > cioff) {
Expand Down

0 comments on commit 2599c19

Please sign in to comment.