Skip to content
Permalink
Browse files Browse the repository at this point in the history
Check length of env stack before accessing upvar; fix #3995
  • Loading branch information
matz committed Apr 11, 2018
1 parent e340b17 commit 1905091
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/vm.c
Expand Up @@ -1201,11 +1201,11 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
mrb_value *regs_a = regs + a;
struct REnv *e = uvenv(mrb, c);

if (!e) {
*regs_a = mrb_nil_value();
if (e && b < MRB_ENV_STACK_LEN(e)) {
*regs_a = e->stack[b];
}
else {
*regs_a = e->stack[b];
*regs_a = mrb_nil_value();
}
NEXT;
}
Expand Down

0 comments on commit 1905091

Please sign in to comment.