mruby-fiber/fiber.c (fiber_switch): check c->cibase->proc env is NULL

ref #6060
This commit is contained in:
Yukihiro "Matz" Matsumoto
2023-09-22 19:36:33 +09:00
parent 0730bda60e
commit 9ee7edc1ac
+8 -1
View File
@@ -257,7 +257,14 @@ fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mr
}
}
c->cibase->n = (uint8_t)len;
value = c->stbase[0] = MRB_PROC_ENV(c->cibase->proc)->stack[0];
struct REnv *env = MRB_PROC_ENV(c->cibase->proc);
if (env && env->stack) {
value = env->stack[0];
}
else {
value = mrb_top_self(mrb);
}
c->stbase[0] = value;
}
else {
value = fiber_result(mrb, a, len);