Skip to content

Commit 99d3a03

Browse files
committed
Raise RangeError when Time.new is called with argument that doesn't fit in Java Integer
1 parent 5d52e0b commit 99d3a03

File tree

1 file changed

+8
-0
lines changed
  • src/main/ruby/truffleruby/core

1 file changed

+8
-0
lines changed

src/main/ruby/truffleruby/core/time.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,14 @@ def at(sec, sub_sec = undefined, unit = undefined, **kwargs)
372372
end
373373

374374
def from_array(sec, min, hour, mday, month, year, nsec, is_dst, is_utc, utc_offset)
375+
# Ensure all the user provided numeric values fit into int type.
376+
# sec and nsec are handled separately.
377+
Primitive.rb_num2int(min)
378+
Primitive.rb_num2int(hour)
379+
Primitive.rb_num2int(mday)
380+
Primitive.rb_num2int(month)
381+
Primitive.rb_num2int(year)
382+
375383
time = Primitive.time_s_from_array(self, sec, min, hour, mday, month, year, nsec, is_dst, is_utc, utc_offset)
376384
return time unless Primitive.undefined?(time)
377385

0 commit comments

Comments
 (0)