Skip to content

Commit 8e57887

Browse files
committed
added the check for negative sec
1 parent 1f0a0fb commit 8e57887

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/timeout.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def self.ensure_timeout_thread_created
164164
# Timeout</tt> into your classes so they have a #timeout method, as well as
165165
# a module method, so you can call it directly as Timeout.timeout().
166166
def timeout(sec, klass = nil, message = nil, &block) #:yield: +sec+
167+
raise ArgumentError, "Timeout sec must be a positive number" unless sec.is_a?(Numeric) && sec >= 0
167168
return yield(sec) if sec == nil or sec.zero?
168169

169170
message ||= "execution expired"

0 commit comments

Comments
 (0)