Skip to content

Commit c51d40c

Browse files
Mat Carterwangweij
authored andcommitted
8303607: SunMSCAPI provider leaks memory and keys
Reviewed-by: weijun
1 parent f64ed09 commit c51d40c

File tree

1 file changed

+5
-1
lines changed
  • src/jdk.crypto.mscapi/windows/native/libsunmscapi

1 file changed

+5
-1
lines changed

src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,11 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_CKeyStore_loadKeysOrCertificateC
523523
else
524524
{
525525
if (bCallerFreeProv == TRUE) {
526-
::CryptReleaseContext(hCryptProv, NULL); // deprecated
526+
if ((dwKeySpec & CERT_NCRYPT_KEY_SPEC) == CERT_NCRYPT_KEY_SPEC) {
527+
NCryptFreeObject(hCryptProv);
528+
} else {
529+
::CryptReleaseContext(hCryptProv, NULL); // deprecated
530+
}
527531
bCallerFreeProv = FALSE;
528532
}
529533

0 commit comments

Comments
 (0)