summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-13 15:19:48 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-13 15:19:48 +0000
commitb9eeeac5c87591ca43fdb6aaafb521a84d7d3800 (patch)
tree4bec4a0c5632fb287658ccdf390a103f4603337e
parent74c6e2af741cc383401a7b1d04336168f1fc5fae (diff)
* bignum.c (big_shift): Avoid signed integer overflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--bignum.c2
2 files changed, 5 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 4c555d39aae..bcd72e5369c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sun Jul 14 00:17:42 2013 Tanaka Akira <akr@fsij.org>
+
+ * bignum.c (big_shift): Avoid signed integer overflow.
+
Sun Jul 14 00:14:15 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (bary_mul_precheck): Use bary_small_lshift or
diff --git a/bignum.c b/bignum.c
index a20f8369fde..fb3954624c9 100644
--- a/bignum.c
+++ b/bignum.c
@@ -5283,7 +5283,7 @@ static VALUE
big_shift(VALUE x, long n)
{
if (n < 0)
- return big_lshift(x, (unsigned long)-n);
+ return big_lshift(x, 1+(unsigned long)(-(n+1)));
else if (n > 0)
return big_rshift(x, (unsigned long)n);
return x;