8303607: SunMSCAPI provider leaks memory and keys

Reviewed-by: weijun
This commit is contained in:
Mat Carter 2023-03-07 02:12:30 +00:00 committed by Weijun Wang
parent f64ed09e9a
commit c51d40cfeb

View File

@ -523,7 +523,11 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_CKeyStore_loadKeysOrCertificateC
else
{
if (bCallerFreeProv == TRUE) {
::CryptReleaseContext(hCryptProv, NULL); // deprecated
if ((dwKeySpec & CERT_NCRYPT_KEY_SPEC) == CERT_NCRYPT_KEY_SPEC) {
NCryptFreeObject(hCryptProv);
} else {
::CryptReleaseContext(hCryptProv, NULL); // deprecated
}
bCallerFreeProv = FALSE;
}