зеркало из https://github.com/github/ruby.git
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
This commit is contained in:
Родитель
f35fb6d36c
Коммит
fe6615b31d
1
bignum.c
1
bignum.c
|
@ -6830,6 +6830,7 @@ estimate_initial_sqrt(VALUE *xp, const size_t xn, const BDIGIT *nds, size_t len)
|
||||||
if (rshift >= 0) {
|
if (rshift >= 0) {
|
||||||
d <<= rshift;
|
d <<= rshift;
|
||||||
}
|
}
|
||||||
|
BDIGITS_ZERO(xds, xn-2);
|
||||||
bdigitdbl2bary(&xds[xn-2], 2, d);
|
bdigitdbl2bary(&xds[xn-2], 2, d);
|
||||||
|
|
||||||
if (!lowbits) return NULL; /* special case, exact result */
|
if (!lowbits) return NULL; /* special case, exact result */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче