mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
class.c: prevent crash in instance_eval; fix #6570
Fixes a null pointer dereference in `find_visibility_scope` when defining a singleton method inside `instance_eval`. This was caused by `ci->u.env` being `NULL` in this context. The fix adds a `NULL` check to prevent the crash. Co-authored-by: Gemini <gemini@google.com>
This commit is contained in:
+1
-2
@@ -950,8 +950,7 @@ find_visibility_scope(mrb_state *mrb, const struct RClass *c, int n, mrb_callinf
|
||||
if (c == NULL) c = mrb_vm_ci_target_class(ci);
|
||||
|
||||
if (check_visibility_break(p, c, ci, NULL)) {
|
||||
mrb_assert(ci->u.env);
|
||||
*ep = (ci->u.env->tt == MRB_TT_ENV ? ci->u.env : NULL);
|
||||
*ep = (ci->u.env && ci->u.env->tt == MRB_TT_ENV) ? ci->u.env : NULL;
|
||||
*cp = ci;
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user