8272541: Incorrect overflow test in Toom-Cook branch of BigInteger multiplication

Reviewed-by: darcy
This commit is contained in:
Brian Burkhalter 2021-08-27 16:09:28 +00:00
parent dfeb4132e4
commit d1aeca117c
2 changed files with 27 additions and 12 deletions

View file

@ -1670,8 +1670,8 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
// are only considering the magnitudes as non-negative. The
// Toom-Cook multiplication algorithm determines the sign
// at its end from the two signum values.
if (bitLength(mag, mag.length) +
bitLength(val.mag, val.mag.length) >
if ((long)bitLength(mag, mag.length) +
(long)bitLength(val.mag, val.mag.length) >
32L*MAX_MAG_LENGTH) {
reportOverflow();
}