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

parent e340b172
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment