summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-11-10 14:08:48 (GMT)
committerSwift Review <review@swift.im>2015-11-10 15:23:29 (GMT)
commite754657d808cf12fd520e84a4b407be892d35c31 (patch)
tree41f7f1333bd1611f22ab8697a448a1c9859d39ba
parent5c5a2d35583915653408aad0b48a9b648ae3191a (diff)
downloadswift-e754657d808cf12fd520e84a4b407be892d35c31.zip
swift-e754657d808cf12fd520e84a4b407be892d35c31.tar.bz2
Fix Cocoa memory management error in Secure Transport backend
The code was calling CFRelease on a null pointer, which runs into an assert inside CFRelease. Test-Information: The crash happened during client certificate authentication using the Secure Transport backend. With this patch the crash is gone. Change-Id: If389dcb8b8a20fdc5cf77219d6c5afb86c9c3634
-rw-r--r--Swiften/TLS/SecureTransport/SecureTransportContext.mm15
1 files changed, 13 insertions, 2 deletions
diff --git a/Swiften/TLS/SecureTransport/SecureTransportContext.mm b/Swiften/TLS/SecureTransport/SecureTransportContext.mm
index a702cde..2357579 100644
--- a/Swiften/TLS/SecureTransport/SecureTransportContext.mm
+++ b/Swiften/TLS/SecureTransport/SecureTransportContext.mm
@@ -72,12 +72,23 @@ CFArrayRef CreateClientCertificateChainAsCFArrayRef(CertificateWithKey::ref key)
break;
case errSecAuthFailed:
// Password did not work for decoding the certificate.
+ SWIFT_LOG(warning) << "Invalid password." << std::endl;
+ break;
case errSecDecode:
// Other decoding error.
+ SWIFT_LOG(warning) << "PKCS12 decoding error." << std::endl;
+ break;
default:
- CFRelease(certChain);
+ SWIFT_LOG(warning) << "Unknown error." << std::endl;
+ }
+
+ if (securityError != errSecSuccess) {
+ if (items) {
CFRelease(items);
- certChain = NULL;
+ items = NULL;
+ }
+ CFRelease(certChain);
+ certChain = NULL;
}
if (certChain) {