[前][次][番号順一覧][スレッド一覧]

ruby-changes:29907

From: akr <ko1@a...>
Date: Sun, 14 Jul 2013 00:19:59 +0900 (JST)
Subject: [ruby-changes:29907] akr:r41959 (trunk): * bignum.c (big_shift): Avoid signed integer overflow.

akr	2013-07-14 00:19:48 +0900 (Sun, 14 Jul 2013)

  New Revision: 41959

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41959

  Log:
    * bignum.c (big_shift): Avoid signed integer overflow.

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41958)
+++ ChangeLog	(revision 41959)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Jul 14 00:17:42 2013  Tanaka Akira  <akr@f...>
+
+	* bignum.c (big_shift): Avoid signed integer overflow.
+
 Sun Jul 14 00:14:15 2013  Tanaka Akira  <akr@f...>
 
 	* bignum.c (bary_mul_precheck): Use bary_small_lshift or
Index: bignum.c
===================================================================
--- bignum.c	(revision 41958)
+++ bignum.c	(revision 41959)
@@ -5283,7 +5283,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/bignum.c#L5283
 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;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]