summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-10 15:45:34 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-10 15:45:34 +0000
commitcb962c5ae59f9237038d6400d9c1e709bed80efd (patch)
tree6bb431b80ce0062183c641c466a3a7519de04b34 /time.c
parent42eca4f46e2cf48a0a1a66bc5d6599c8414bb67e (diff)
* time.c (rb_localtime_r2): fix localtime overflow check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/time.c b/time.c
index 5acc64345c..6c5a4f20d0 100644
--- a/time.c
+++ b/time.c
@@ -872,12 +872,13 @@ rb_localtime_r2(const time_t *t, struct tm *result)
if (result) {
int gmtoff1 = 0;
int gmtoff2 = 0;
+ struct tm tmp = *result;
# if defined(HAVE_STRUCT_TM_TM_GMTOFF)
gmtoff1 = result->tm_gmtoff;
# endif
- time_t t2 = mktime(result);
+ time_t t2 = mktime(&tmp);
# if defined(HAVE_STRUCT_TM_TM_GMTOFF)
- gmtoff2 = result->tm_gmtoff;
+ gmtoff2 = tmp.tm_gmtoff;
# endif
if (*t + gmtoff1 != t2 + gmtoff2)
result = NULL;
@@ -894,7 +895,8 @@ rb_localtime_r2(const time_t *t, struct tm *result)
result = rb_gmtime_r(t, result);
#if defined(HAVE_TIMEGM) && defined(LOCALTIME_OVERFLOW_PROBLEM)
if (result) {
- time_t t2 = timegm(result);
+ struct tm tmp = *result;
+ time_t t2 = timegm(&tmp);
if (*t != t2)
result = NULL;
}