mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8258915: Temporary buffer cleanup
Reviewed-by: valeriep
This commit is contained in:
parent
31d8a19e47
commit
f834557ae0
79 changed files with 1517 additions and 1039 deletions
|
@ -688,7 +688,23 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
|||
* @see #bitLength()
|
||||
*/
|
||||
public BigInteger(int numBits, Random rnd) {
|
||||
this(1, randomBits(numBits, rnd));
|
||||
byte[] magnitude = randomBits(numBits, rnd);
|
||||
|
||||
try {
|
||||
// stripLeadingZeroBytes() returns a zero length array if len == 0
|
||||
this.mag = stripLeadingZeroBytes(magnitude, 0, magnitude.length);
|
||||
|
||||
if (this.mag.length == 0) {
|
||||
this.signum = 0;
|
||||
} else {
|
||||
this.signum = 1;
|
||||
}
|
||||
if (mag.length >= MAX_MAG_LENGTH) {
|
||||
checkRange();
|
||||
}
|
||||
} finally {
|
||||
Arrays.fill(magnitude, (byte)0);
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] randomBits(int numBits, Random rnd) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue