8187496: Possible memory leak in java.apple.security.KeychainStore.addItemToKeychain
Reviewed-by: weijun, mullan, ahgross
This commit is contained in:
parent
8ea00aed64
commit
29534320cd
@ -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…
x
Reference in New Issue
Block a user