Skip to content
Permalink
Browse files
Clear local (but non-argument) variables in OP_ENTER.
Otherwise, the following script prints an uninitialized value.

def f(*a)
  if false
    b = 15
  end
  p b
end
f(1,2,3)
  • Loading branch information
matz committed Apr 9, 2017
1 parent 47f1815 commit c063641ab0c32ab19715342a4856ed040a1fde14
Showing 1 changed file with 4 additions and 0 deletions.
@@ -1637,6 +1637,10 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
}
pc += o + 1;
}
/* clear local (but non-argument) variables */
if (irep->nlocals-len-2 > 0) {
stack_clear(&regs[len+2], irep->nlocals-len-2);
}
JUMP;
}

0 comments on commit c063641

Please sign in to comment.