mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8187496: Possible memory leak in java.apple.security.KeychainStore.addItemToKeychain
Reviewed-by: weijun, mullan, ahgross
This commit is contained in:
parent
8ea00aed64
commit
29534320cd
1 changed files with 22 additions and 12 deletions
|
@ -438,12 +438,11 @@ JNIEXPORT jbyteArray JNICALL Java_apple_security_KeychainStore__1getEncodedKeyDa
|
|||
if (passwordChars == NULL) {
|
||||
goto errOut;
|
||||
}
|
||||
passwordStrRef = CFStringCreateWithCharacters(kCFAllocatorDefault, passwordChars, passwordLen);
|
||||
|
||||
// clear the password and release
|
||||
memset(passwordChars, 0, passwordLen);
|
||||
(*env)->ReleaseCharArrayElements(env, passwordObj, passwordChars,
|
||||
JNI_ABORT);
|
||||
passwordStrRef = CFStringCreateWithCharactersNoCopy(NULL, passwordChars, passwordLen, kCFAllocatorNull);
|
||||
if (passwordStrRef == NULL) {
|
||||
goto errOut;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -471,7 +470,12 @@ JNIEXPORT jbyteArray JNICALL Java_apple_security_KeychainStore__1getEncodedKeyDa
|
|||
errOut:
|
||||
if (exportedData) CFRelease(exportedData);
|
||||
if (passwordStrRef) CFRelease(passwordStrRef);
|
||||
|
||||
if (passwordChars) {
|
||||
// clear the password and release
|
||||
memset(passwordChars, 0, passwordLen);
|
||||
(*env)->ReleaseCharArrayElements(env, passwordObj, passwordChars,
|
||||
JNI_ABORT);
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
@ -538,12 +542,11 @@ JNF_COCOA_ENTER(env);
|
|||
if (passwordChars == NULL) {
|
||||
goto errOut;
|
||||
}
|
||||
passwordStrRef = CFStringCreateWithCharacters(kCFAllocatorDefault, passwordChars, passwordLen);
|
||||
|
||||
// clear the password and release
|
||||
memset(passwordChars, 0, passwordLen);
|
||||
(*env)->ReleaseCharArrayElements(env, passwordObj, passwordChars,
|
||||
JNI_ABORT);
|
||||
passwordStrRef = CFStringCreateWithCharactersNoCopy(NULL, passwordChars, passwordLen, kCFAllocatorNull);
|
||||
if (passwordStrRef == NULL) {
|
||||
goto errOut;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -581,7 +584,14 @@ JNF_COCOA_ENTER(env);
|
|||
CFRelease(createdItems);
|
||||
}
|
||||
|
||||
errOut: ;
|
||||
errOut:
|
||||
if (passwordStrRef) CFRelease(passwordStrRef);
|
||||
if (passwordChars) {
|
||||
// clear the password and release
|
||||
memset(passwordChars, 0, passwordLen);
|
||||
(*env)->ReleaseCharArrayElements(env, passwordObj, passwordChars,
|
||||
JNI_ABORT);
|
||||
}
|
||||
|
||||
JNF_COCOA_EXIT(env);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue