From 67be29c1141df73179694dc3cdf27162b23ffeeb Mon Sep 17 00:00:00 2001 From: matz Date: Sat, 7 Oct 2006 15:49:00 +0000 Subject: * bignum.c (rb_big_rshift): a bug in right shift of negative bignums. [ruby-core:09020] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@11104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ bignum.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 968319388..c1b937f81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Oct 7 23:44:33 2006 Yukihiro Matsumoto + + * bignum.c (rb_big_rshift): a bug in right shift of negative + bignums. [ruby-core:09020] + Sat Oct 7 23:33:02 2006 Yukihiro Matsumoto * eval.c (formal_assign): packed post splat arguments may conflict diff --git a/bignum.c b/bignum.c index ecf2872f0..17424b514 100644 --- a/bignum.c +++ b/bignum.c @@ -1811,6 +1811,10 @@ rb_big_rshift(VALUE x, VALUE y) } xds = BDIGITS(x); i = RBIGNUM(x)->len; j = i - s1; + if (j == 0) { + if (RBIGNUM(x)->sign) return INT2FIX(0); + else return INT2FIX(-1); + } z = bignew(j, RBIGNUM(x)->sign); if (!RBIGNUM(x)->sign) { num = ((BDIGIT_DBL)~0) << BITSPERDIG; -- cgit