mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Check for switching to uninitialized fiber; fix #4041
The problem was caused by `Fiber.current.resume'.
This commit is contained in:
@@ -196,7 +196,7 @@ fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mr
|
||||
mrb_raise(mrb, E_FIBER_ERROR, "resuming transferred fiber");
|
||||
}
|
||||
if (status == MRB_FIBER_RUNNING || status == MRB_FIBER_RESUMED) {
|
||||
mrb_raise(mrb, E_FIBER_ERROR, "double resume (fib)");
|
||||
mrb_raise(mrb, E_FIBER_ERROR, "double resume");
|
||||
}
|
||||
if (status == MRB_FIBER_TERMINATED) {
|
||||
mrb_raise(mrb, E_FIBER_ERROR, "resuming dead fiber");
|
||||
@@ -207,6 +207,9 @@ fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mr
|
||||
if (status == MRB_FIBER_CREATED) {
|
||||
mrb_value *b, *e;
|
||||
|
||||
if (!c->ci->proc) {
|
||||
mrb_raise(mrb, E_FIBER_ERROR, "double resume (current)");
|
||||
}
|
||||
mrb_stack_extend(mrb, len+2); /* for receiver and (optional) block */
|
||||
b = c->stack+1;
|
||||
e = b + len;
|
||||
|
||||
Reference in New Issue
Block a user