diff options
author | rhe <rhe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-02 06:30:18 +0000 |
---|---|---|
committer | rhe <rhe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-02 06:30:18 +0000 |
commit | fe6615b31de428c80ca23ba997a5640a41bca237 (patch) | |
tree | 56c62dfe5b8dd2a37fd11a1c92c17a91c338bd7a /bignum.c | |
parent | f35fb6d36c3218988b17dbeb4412922c23745f0e (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.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -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 */ |