aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-04-22 11:25:26 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-04-22 11:25:26 +0000
commita397887e58da366f5c009a31e4b8b4725a8865d8 (patch)
tree31146b379353c32d60754bb8eadbb6b6adbe7b76
parent258ed42c12ab2d0d2d23cbd0b5bcbd60f3ed55d6 (diff)
downloadruby-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
-rw-r--r--ChangeLog5
-rw-r--r--time.c9
2 files changed, 11 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 66f2ca11b5..3a85849f4a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
-Wed Apr 22 19:33:13 2009 Tanaka Akira <akr@fsij.org>
+Wed Apr 22 20:25:24 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * lib/time.rb (Time.parse): use year completion in Date._parse.
+ * time.c (time_timespec): check out-of-range. [ruby-core:23282]
+ [Bug #1396]
Wed Apr 22 11:12:15 2009 NAKAMURA Usaku <usa@ruby-lang.org>
diff --git a/time.c b/time.c
index 68f26aa3c1..010a2f026e 100644
--- a/time.c
+++ b/time.c
@@ -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;