mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Don't allow rb_fiber_resume to raise exception on unborn fiber.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5fb9d1e11f
commit
9ee79b6581
2 changed files with 6 additions and 0 deletions
5
cont.c
5
cont.c
|
@ -1896,9 +1896,14 @@ rb_fiber_resume(VALUE fibval, int argc, const VALUE *argv)
|
|||
{
|
||||
rb_fiber_t *fib = fiber_ptr(fibval);
|
||||
|
||||
if (argc == -1 && FIBER_CREATED_P(fib)) {
|
||||
rb_raise(rb_eFiberError, "cannot raise exception on unborn fiber");
|
||||
}
|
||||
|
||||
if (fib->prev != 0 || fiber_is_root_p(fib)) {
|
||||
rb_raise(rb_eFiberError, "double resume");
|
||||
}
|
||||
|
||||
if (fib->transferred != 0) {
|
||||
rb_raise(rb_eFiberError, "cannot resume transferred Fiber");
|
||||
}
|
||||
|
|
|
@ -144,6 +144,7 @@ class TestFiber < Test::Unit::TestCase
|
|||
}
|
||||
assert_raise(RuntimeError){
|
||||
fib = Fiber.new{ Fiber.yield }
|
||||
fib.resume
|
||||
fib.raise "raise and propagate"
|
||||
}
|
||||
assert_nothing_raised{
|
||||
|
|
Loading…
Reference in a new issue