summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-01 13:34:52 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-01 13:34:52 +0000
commit87877eb04f5376b651e501cd7aa451c870df7411 (patch)
tree75e2d535e44e0553d91ea9a8ea00d93aed3edd82 /ext
parentf4eeca1d161d398971ef7da1c3765f206b35f477 (diff)
* ext/zlib/zlib.c (rb_gzfile_set_mtime): Use NUM2UINT.
The old logic doesn't work well on LP64 platforms as: .. -2**63-1 => error, -2**63 .. -2**62-1 => success, -2**62 .. -2**31-1 => error, -2**31 .. 2**31-1 => success, 2**31 .. 2**62-1 => error, 2**62 .. 2**64-1 => success, 2**64 .. => error. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/zlib/zlib.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index c550f46..e5a1e67 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -3188,13 +3188,9 @@ rb_gzfile_set_mtime(VALUE obj, VALUE mtime)
rb_raise(cGzError, "header is already written");
}
- if (FIXNUM_P(mtime)) {
- gz->mtime = FIX2INT(mtime);
- }
- else {
- val = rb_Integer(mtime);
- gz->mtime = FIXNUM_P(val) ? FIX2UINT(val) : rb_big2ulong(val);
- }
+ val = rb_Integer(mtime);
+ gz->mtime = NUM2UINT(val);
+
return mtime;
}