Skip to content

Commit

Permalink
Raise an exception when transfer arguments are too many; fix #3641
Browse files Browse the repository at this point in the history
The fix was proposed by @block8437.  Thank you.
  • Loading branch information
matz committed May 25, 2017
1 parent de48d95 commit ac442bc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mrbgems/mruby-fiber/src/fiber.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down

0 comments on commit ac442bc

Please sign in to comment.