8268525: Some new memory leak after JDK-8248268 and JDK-8255557

Reviewed-by: valeriep, ascarpino
This commit is contained in:
Weijun Wang 2021-06-10 22:18:38 +00:00
parent 53b6e2c85c
commit 7b2e7d8bab
5 changed files with 91 additions and 108 deletions

View file

@ -472,7 +472,11 @@ abstract class KeyWrapCipher extends CipherSpi {
int outLen = engineDoFinal(in, inOfs, inLen, out, 0);
if (outLen < estOutLen) {
return Arrays.copyOf(out, outLen);
try {
return Arrays.copyOf(out, outLen);
} finally {
Arrays.fill(out, (byte)0);
}
} else {
return out;
}
@ -529,6 +533,9 @@ abstract class KeyWrapCipher extends CipherSpi {
return outLen;
}
} finally {
if (dataBuf != null) {
Arrays.fill(dataBuf, (byte)0);
}
dataBuf = null;
dataIdx = 0;
}
@ -559,8 +566,14 @@ abstract class KeyWrapCipher extends CipherSpi {
len += inLen;
}
return (opmode == Cipher.ENCRYPT_MODE?
helperEncrypt(out, len) : helperDecrypt(out, len));
try {
return (opmode == Cipher.ENCRYPT_MODE ?
helperEncrypt(out, len) : helperDecrypt(out, len));
} finally {
if (dataBuf != null && dataBuf != out) {
Arrays.fill(dataBuf, (byte)0);
}
}
}
// helper routine for in-place encryption.