mirror of
https://github.com/curl/curl.git
synced 2024-12-27 06:59:43 +08:00
sectransp: prevent CFRelease() of NULL
When SecCertificateCopyCommonName() returns NULL, the common_name pointer remains set to NULL which apparently when calling CFRelease() on (sometimes?) crashes. Reported-by: Guillaume Algis Fixes #9194 Closes #11554
This commit is contained in:
parent
2fcb674cdf
commit
0b947e8ca2
@ -1086,7 +1086,6 @@ static OSStatus CopyIdentityWithLabel(char *label,
|
||||
CFArrayRef keys_list;
|
||||
CFIndex keys_list_count;
|
||||
CFIndex i;
|
||||
CFStringRef common_name;
|
||||
|
||||
/* SecItemCopyMatching() was introduced in iOS and Snow Leopard.
|
||||
kSecClassIdentity was introduced in Lion. If both exist, let's use them
|
||||
@ -1134,6 +1133,7 @@ static OSStatus CopyIdentityWithLabel(char *label,
|
||||
(SecIdentityRef) CFArrayGetValueAtIndex(keys_list, i);
|
||||
err = SecIdentityCopyCertificate(identity, &cert);
|
||||
if(err == noErr) {
|
||||
CFStringRef common_name = NULL;
|
||||
OSStatus copy_status = noErr;
|
||||
#if CURL_BUILD_IOS
|
||||
common_name = SecCertificateCopySubjectSummary(cert);
|
||||
@ -1149,7 +1149,8 @@ static OSStatus CopyIdentityWithLabel(char *label,
|
||||
status = noErr;
|
||||
break;
|
||||
}
|
||||
CFRelease(common_name);
|
||||
if(common_name)
|
||||
CFRelease(common_name);
|
||||
}
|
||||
CFRelease(cert);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user