diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-04-22 11:25:26 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-04-22 11:25:26 +0000 |
commit | a397887e58da366f5c009a31e4b8b4725a8865d8 (patch) | |
tree | 31146b379353c32d60754bb8eadbb6b6adbe7b76 /time.c | |
parent | 258ed42c12ab2d0d2d23cbd0b5bcbd60f3ed55d6 (diff) | |
download | ruby-a397887e58da366f5c009a31e4b8b4725a8865d8.tar.gz |
* time.c (time_timespec): check out-of-range. [ruby-core:23282]
[Bug #1396]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r-- | time.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -1217,7 +1217,14 @@ time_timespec(VALUE num, int interval) if (f != t.tv_sec) { rb_raise(rb_eRangeError, "%f out of Time range", RFLOAT_VALUE(num)); } - t.tv_nsec = (long)(d*1e9+0.5); + t.tv_nsec = (int)(d*1e9+0.5); + if (t.tv_nsec >= 1000000000) { + t.tv_nsec -= 1000000000; + if (++t.tv_sec <= 0) { + --t.tv_nsec; + t.tv_nsec = 999999999; + } + } } break; |