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) {
|
if (passwordChars == NULL) {
|
||||||
goto errOut;
|
goto errOut;
|
||||||
}
|
}
|
||||||
passwordStrRef = CFStringCreateWithCharacters(kCFAllocatorDefault, passwordChars, passwordLen);
|
|
||||||
|
|
||||||
// clear the password and release
|
passwordStrRef = CFStringCreateWithCharactersNoCopy(NULL, passwordChars, passwordLen, kCFAllocatorNull);
|
||||||
memset(passwordChars, 0, passwordLen);
|
if (passwordStrRef == NULL) {
|
||||||
(*env)->ReleaseCharArrayElements(env, passwordObj, passwordChars,
|
goto errOut;
|
||||||
JNI_ABORT);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,7 +470,12 @@ JNIEXPORT jbyteArray JNICALL Java_apple_security_KeychainStore__1getEncodedKeyDa
|
|||||||
errOut:
|
errOut:
|
||||||
if (exportedData) CFRelease(exportedData);
|
if (exportedData) CFRelease(exportedData);
|
||||||
if (passwordStrRef) CFRelease(passwordStrRef);
|
if (passwordStrRef) CFRelease(passwordStrRef);
|
||||||
|
if (passwordChars) {
|
||||||
|
// clear the password and release
|
||||||
|
memset(passwordChars, 0, passwordLen);
|
||||||
|
(*env)->ReleaseCharArrayElements(env, passwordObj, passwordChars,
|
||||||
|
JNI_ABORT);
|
||||||
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,12 +542,11 @@ JNF_COCOA_ENTER(env);
|
|||||||
if (passwordChars == NULL) {
|
if (passwordChars == NULL) {
|
||||||
goto errOut;
|
goto errOut;
|
||||||
}
|
}
|
||||||
passwordStrRef = CFStringCreateWithCharacters(kCFAllocatorDefault, passwordChars, passwordLen);
|
|
||||||
|
|
||||||
// clear the password and release
|
passwordStrRef = CFStringCreateWithCharactersNoCopy(NULL, passwordChars, passwordLen, kCFAllocatorNull);
|
||||||
memset(passwordChars, 0, passwordLen);
|
if (passwordStrRef == NULL) {
|
||||||
(*env)->ReleaseCharArrayElements(env, passwordObj, passwordChars,
|
goto errOut;
|
||||||
JNI_ABORT);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -581,7 +584,14 @@ JNF_COCOA_ENTER(env);
|
|||||||
CFRelease(createdItems);
|
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);
|
JNF_COCOA_EXIT(env);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user