File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3971,7 +3971,7 @@ static void
39713971set_timeout (rb_hrtime_t * hrt , VALUE timeout )
39723972{
39733973 double timeout_d = NIL_P (timeout ) ? 0.0 : NUM2DBL (timeout );
3974- if (!NIL_P (timeout ) && timeout_d <= 0 ) {
3974+ if (!NIL_P (timeout ) && !( timeout_d > 0 ) ) {
39753975 rb_raise (rb_eArgError , "invalid timeout: %" PRIsVALUE , timeout );
39763976 }
39773977 double2hrtime (hrt , timeout_d );
Original file line number Diff line number Diff line change @@ -2035,6 +2035,7 @@ def test_s_timeout_corner_cases
20352035 Regexp.timeout = 1e300
20362036 assert_equal(((1<<64)-1) / 1000000000.0, Regexp.timeout)
20372037
2038+ assert_raise(ArgumentError) { Regexp.timeout = Float::NAN }
20382039 assert_raise(ArgumentError) { Regexp.timeout = 0 }
20392040 assert_raise(ArgumentError) { Regexp.timeout = -1 }
20402041
@@ -2127,6 +2128,7 @@ def test_timeout_corner_cases
21272128
21282129 assert_equal(((1<<64)-1) / 1000000000.0, Regexp.new("foo", timeout: 1e300).timeout)
21292130
2131+ assert_raise(ArgumentError) { Regexp.new("foo", timeout: Float::NAN) }
21302132 assert_raise(ArgumentError) { Regexp.new("foo", timeout: 0) }
21312133 assert_raise(ArgumentError) { Regexp.new("foo", timeout: -1) }
21322134 end;
You can’t perform that action at this time.
0 commit comments