Skip to content

Commit a393f25

Browse files
Mat CarterPaul Hohensee
authored andcommitted
8303607: SunMSCAPI provider leaks memory and keys
Backport-of: c51d40cfebe793b2e979db0f2d91ac3b136311bb
1 parent d7e22e8 commit a393f25

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)