Check env stack length before OP_SETUPVAR; ref #3643

This commit is contained in:
Yukihiro "Matz" Matsumoto
2017-05-25 14:12:16 +09:00
parent e969229b77
commit e0931126ff
+5 -2
View File
@@ -1084,8 +1084,11 @@ RETRY_TRY_BLOCK:
if (e) {
mrb_value *regs_a = regs + GETARG_A(i);
int idx = GETARG_B(i);
e->stack[idx] = *regs_a;
mrb_write_barrier(mrb, (struct RBasic*)e);
if (idx < MRB_ENV_STACK_LEN(e)) {
e->stack[idx] = *regs_a;
mrb_write_barrier(mrb, (struct RBasic*)e);
}
}
NEXT;
}