From e754657d808cf12fd520e84a4b407be892d35c31 Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Tue, 10 Nov 2015 15:08:48 +0100 Subject: 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 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) { -- cgit v0.10.2-6-g49f6