* 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
This commit is contained in:
akr 2013-07-13 15:19:48 +00:00
parent 74c6e2af74
commit b9eeeac5c8
2 changed files with 5 additions and 1 deletions

View file

@ -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

View file

@ -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;