diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-09-04 13:50:32 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-09-04 13:50:32 +0900 |
| commit | 2d8f4fa92fe14d5ec012533ade65eb013a8fc73a (patch) | |
| tree | 72e30acc595de883b833a4a43868ebcfd8d363a7 /src/proc.c | |
| parent | 5acf7e7cf7e834d236df9450c2da8c15497749e8 (diff) | |
| download | mruby-2d8f4fa92fe14d5ec012533ade65eb013a8fc73a.tar.gz mruby-2d8f4fa92fe14d5ec012533ade65eb013a8fc73a.zip | |
proc.c: need to preserve `target_class` in `callinfo`.
Otherwise `target_class` can be lost when it differs from `proc`'s
`target_class`, e.g. when called from `instance_eval`.
Also we should not pass `target_class` to `MRB_OBJ_ALLOC` since it
checks instance type from the class, and `target_class` may not have
proper information. ref #5272
Diffstat (limited to 'src/proc.c')
| -rw-r--r-- | src/proc.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/proc.c b/src/proc.c index 6b3e19a6b..d48145f13 100644 --- a/src/proc.c +++ b/src/proc.c @@ -81,7 +81,8 @@ mrb_env_new(mrb_state *mrb, struct mrb_context *c, mrb_callinfo *ci, int nstacks struct REnv *e; mrb_int bidx; - e = MRB_OBJ_ALLOC(mrb, MRB_TT_ENV, tc); + e = MRB_OBJ_ALLOC(mrb, MRB_TT_ENV, NULL); + e->c = tc; MRB_ENV_SET_LEN(e, nstacks); bidx = ci->argc; if (bidx < 0) bidx = 2; @@ -105,7 +106,7 @@ closure_setup(mrb_state *mrb, struct RProc *p) /* do nothing, because e is assigned already */ } else if (up) { - struct RClass *tc = MRB_PROC_TARGET_CLASS(p); + struct RClass *tc = ci->u.target_class; e = mrb_env_new(mrb, mrb->c, ci, up->body.irep->nlocals, ci->stack, tc); ci->u.env = e; |
