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>bb10
parent
2f8a08f31b
commit
0d97babf2f
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Reference in New Issue