Skip to content

Commit e093112

Browse files
committed
Check env stack length before OP_SETUPVAR; ref #3643
1 parent e969229 commit e093112

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/vm.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -1084,8 +1084,11 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
10841084
if (e) {
10851085
mrb_value *regs_a = regs + GETARG_A(i);
10861086
int idx = GETARG_B(i);
1087-
e->stack[idx] = *regs_a;
1088-
mrb_write_barrier(mrb, (struct RBasic*)e);
1087+
1088+
if (idx < MRB_ENV_STACK_LEN(e)) {
1089+
e->stack[idx] = *regs_a;
1090+
mrb_write_barrier(mrb, (struct RBasic*)e);
1091+
}
10891092
}
10901093
NEXT;
10911094
}

0 commit comments

Comments
 (0)