Skip to content

Commit 94d3648

Browse files
Mat CarterPaul Hohensee
authored andcommitted
8303607: SunMSCAPI provider leaks memory and keys
Backport-of: a393f2581740f854518a3ef7caccd6d3c2d8e4a0
1 parent 363855d commit 94d3648

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
@@ -502,7 +502,11 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_CKeyStore_loadKeysOrCertificateC
502502
else
503503
{
504504
if (bCallerFreeProv == TRUE) {
505-
::CryptReleaseContext(hCryptProv, NULL); // deprecated
505+
if ((dwKeySpec & CERT_NCRYPT_KEY_SPEC) == CERT_NCRYPT_KEY_SPEC) {
506+
NCryptFreeObject(hCryptProv);
507+
} else {
508+
::CryptReleaseContext(hCryptProv, NULL); // deprecated
509+
}
506510
bCallerFreeProv = FALSE;
507511
}
508512

0 commit comments

Comments
 (0)