Permalink
Browse files

Raise an exception when transfer arguments are too many; fix #3641

The fix was proposed by @block8437.  Thank you.
  • Loading branch information...
matz committed May 25, 2017
1 parent de48d95 commit ac442bc1df2ec26729077ed8d57342cb5c494a21
Showing with 6 additions and 2 deletions.
  1. +6 −2 mrbgems/mruby-fiber/src/fiber.c
@@ -188,9 +188,13 @@ fiber_switch(mrb_state *mrb, mrb_value self, mrb_int len, const mrb_value *a, mr
mrb->c->status = resume ? MRB_FIBER_RESUMED : MRB_FIBER_TRANSFERRED;
c->prev = resume ? mrb->c : (c->prev ? c->prev : mrb->root_c);
if (c->status == MRB_FIBER_CREATED) {
mrb_value *b = c->stack+1;
mrb_value *e = b + len;
mrb_value *b, *e;
if (len > c->stend - c->stack) {
mrb_raise(mrb, E_FIBER_ERROR, "too many arguments to fiber");
}
b = c->stack+1;
e = b + len;
while (b<e) {
*b++ = *a++;
}

0 comments on commit ac442bc

Please sign in to comment.