Unverified Commit e9ddb593 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #3991 from take-cheeze/fix_eval_env_gc

Fix possible heap use after free in `mrb_exec_irep` and stack expanding.
parents f23c3cdd 26e436e2
......@@ -156,6 +156,18 @@ envadjust(mrb_state *mrb, mrb_value *oldbase, mrb_value *newbase, size_t size)
e->stack = newbase + off;
}
if (ci->proc && MRB_PROC_ENV_P(ci->proc) && ci->env != MRB_PROC_ENV(ci->proc)) {
e = MRB_PROC_ENV(ci->proc);
if (e && MRB_ENV_STACK_SHARED_P(e) &&
(st = e->stack) && oldbase <= st && st < oldbase+size) {
ptrdiff_t off = e->stack - oldbase;
e->stack = newbase + off;
}
}
ci->stackent = newbase + (ci->stackent - oldbase);
ci++;
}
......
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