mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1522710 - Assert |!mod->isZero()| in bigint code where such is not entirely obvious unless you think about it. r=terpri
--HG-- extra : rebase_source : 075a2cb07b70744247bb129b24b0c2ff6418da4e
This commit is contained in:
parent
462bfe5e5b
commit
8ca83fbf1e
@ -2347,10 +2347,15 @@ BigInt* BigInt::asIntN(JSContext* cx, HandleBigInt x, uint64_t bits) {
|
||||
|
||||
// Step 4: If `mod >= 2**(bits - 1)`, return `mod - 2**bits`; otherwise,
|
||||
// return `mod`.
|
||||
if (mod->digitLength() == CeilDiv(bits, DigitBits) &&
|
||||
(mod->digit(mod->digitLength() - 1) & signBit) != 0) {
|
||||
bool resultNegative = true;
|
||||
return truncateAndSubFromPowerOfTwo(cx, mod, bits, resultNegative);
|
||||
if (mod->digitLength() == CeilDiv(bits, DigitBits)) {
|
||||
MOZ_ASSERT(!mod->isZero(),
|
||||
"nonzero bits implies nonzero digit length which implies "
|
||||
"nonzero overall");
|
||||
|
||||
if ((mod->digit(mod->digitLength() - 1) & signBit) != 0) {
|
||||
bool resultNegative = true;
|
||||
return truncateAndSubFromPowerOfTwo(cx, mod, bits, resultNegative);
|
||||
}
|
||||
}
|
||||
|
||||
return mod;
|
||||
|
Loading…
Reference in New Issue
Block a user