Check length of env stack before accessing upvar; fix #3995

This commit is contained in:
Yukihiro "Matz" Matsumoto
2018-04-11 10:24:44 +09:00
parent e340b17252
commit 1905091634
+3 -3
View File
@@ -1201,11 +1201,11 @@ RETRY_TRY_BLOCK:
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;
}