summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authorrhe <rhe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-02 06:30:18 +0000
committerrhe <rhe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-02 06:30:18 +0000
commitfe6615b31de428c80ca23ba997a5640a41bca237 (patch)
tree56c62dfe5b8dd2a37fd11a1c92c17a91c338bd7a /bignum.c
parentf35fb6d36c3218988b17dbeb4412922c23745f0e (diff)
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). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/bignum.c b/bignum.c
index 361a12fb19..47b5f57d49 100644
--- a/bignum.c
+++ b/bignum.c
@@ -6830,6 +6830,7 @@ estimate_initial_sqrt(VALUE *xp, const size_t xn, const BDIGIT *nds, size_t len)
if (rshift >= 0) {
d <<= rshift;
}
+ BDIGITS_ZERO(xds, xn-2);
bdigitdbl2bary(&xds[xn-2], 2, d);
if (!lowbits) return NULL; /* special case, exact result */