ruby-changes:48496
From: rhe <ko1@a...>
Date: Thu, 2 Nov 2017 15:30:29 +0900 (JST)
Subject: [ruby-changes:48496] rhe:r60611 (trunk): bignum.c: avoid use of uninitialized value in Integer.sqrt
rhe 2017-11-02 15:30:18 +0900 (Thu, 02 Nov 2017) New Revision: 60611 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60611 Log: bignum.c: avoid use of uninitialized value in Integer.sqrt This is a follow-up fix to r57713. estimate_initial_sqrt() didn't initialize BDIGITs except the topmost two, letting Integer.sqrt return wrong result in the fast path, such as for (1<<504). Modified files: trunk/bignum.c Index: bignum.c =================================================================== --- bignum.c (revision 60610) +++ bignum.c (revision 60611) @@ -6830,6 +6830,7 @@ estimate_initial_sqrt(VALUE *xp, const s https://github.com/ruby/ruby/blob/trunk/bignum.c#L6830 if (rshift >= 0) { d <<= rshift; } + BDIGITS_ZERO(xds, xn-2); bdigitdbl2bary(&xds[xn-2], 2, d); if (!lowbits) return NULL; /* special case, exact result */ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/