summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rw-r--r--ext/zlib/zlib.c10
2 files changed, 15 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index ff328c3..6cee534 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Mon Apr 1 22:26:17 2013 Tanaka Akira <akr@fsij.org>
+
+ * 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.
+
Mon Apr 1 22:08:02 2013 Benoit Daloze <eregontp@gmail.com>
* ext/zlib/zlib.c (Zlib::Inflate.new):
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;
}