diff options
author | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2017-07-03 16:34:19 +0200 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2017-07-04 05:02:11 +0000 |
commit | 0d97babf2ffcc3762e2398c319786a0f78df8aa6 (patch) | |
tree | fc6051774311ce418849ba24ec7180bf59b56aaf /src/network | |
parent | 2f8a08f31b1bfdc18766bae4983d238ee1cf716c (diff) |
QSslSocket - fix two memory management issues (Secure Transport)
I noticed we never release 'items' imported by SecPKCS12Import.
But looking at the actual code (SecImportExport.c), it appears
we own these 'items' and must release them. And this leads to a crash
(on over-release) which reveals another bug: a value from a dictionary
obtained with 'Get' method should follow the 'get rule' - we do not
own it and QCFType RAII object is not needed.
Change-Id: I219015fadedb256c401e50cf7e955f3d7e0a6c5f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/ssl/qsslsocket_mac.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/network/ssl/qsslsocket_mac.cpp b/src/network/ssl/qsslsocket_mac.cpp index 10f6fb4e41..2aecf3407f 100644 --- a/src/network/ssl/qsslsocket_mac.cpp +++ b/src/network/ssl/qsslsocket_mac.cpp @@ -931,7 +931,7 @@ bool QSslSocketBackendPrivate::setSessionCertificate(QString &errorDescription, #endif QCFType<CFDictionaryRef> options = CFDictionaryCreate(nullptr, keys, values, nKeys, nullptr, nullptr); - CFArrayRef items = nullptr; + QCFType<CFArrayRef> items; OSStatus err = SecPKCS12Import(pkcs12, options, &items); if (err != noErr) { #ifdef QSSLSOCKET_DEBUG @@ -972,7 +972,7 @@ bool QSslSocketBackendPrivate::setSessionCertificate(QString &errorDescription, CFArrayAppendValue(certs, identity); - QCFType<CFArrayRef> chain((CFArrayRef)CFDictionaryGetValue(import, kSecImportItemCertChain)); + CFArrayRef chain = (CFArrayRef)CFDictionaryGetValue(import, kSecImportItemCertChain); if (chain) { for (CFIndex i = 1, e = CFArrayGetCount(chain); i < e; ++i) CFArrayAppendValue(certs, CFArrayGetValueAtIndex(chain, i)); |