diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ext/date/date_core.c | 6 |
2 files changed, 9 insertions, 2 deletions
@@ -1,3 +1,8 @@ +Tue Jun 7 13:59:47 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * ext/date/date_core.c (date_s_today, datetime_s_now): check the + result of localtime_r(). + Tue Jun 7 13:36:51 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> * ext/tk/extconf.rb: use $defs not $CPPFLAGS to get rid of diff --git a/ext/date/date_core.c b/ext/date/date_core.c index 309ecfaf6c..e8c7a5f69f 100644 --- a/ext/date/date_core.c +++ b/ext/date/date_core.c @@ -3483,7 +3483,8 @@ date_s_today(int argc, VALUE *argv, VALUE klass) if (time(&t) == -1) rb_sys_fail("time"); - localtime_r(&t, &tm); + if (!localtime_r(&t, &tm)) + rb_sys_fail("localtime"); y = tm.tm_year + 1900; m = tm.tm_mon + 1; @@ -7288,7 +7289,8 @@ datetime_s_now(int argc, VALUE *argv, VALUE klass) rb_sys_fail("gettimeofday"); sec = tv.tv_sec; #endif - localtime_r(&sec, &tm); + if (!localtime_r(&sec, &tm)) + rb_sys_fail("localtime"); y = tm.tm_year + 1900; m = tm.tm_mon + 1; |