SSL internals: certificate verification: use mutex locker
authorPeter Hartmann <peter.hartmann@nokia.com>
Thu, 14 Jul 2011 09:28:32 +0000 (11:28 +0200)
committerQt by Nokia <qt-info@nokia.com>
Thu, 14 Jul 2011 11:08:20 +0000 (13:08 +0200)
there are return statements between locking and unlocking, so to not
leave the mutex locked when returning, this commit introduces a
QMutexLocker.

Change-Id: I74e2f329bf116e92250189bf097deb47d460d9dc
Reviewed-on: http://codereview.qt.nokia.com/1656
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Markus Goetz
src/network/ssl/qsslsocket_openssl.cpp

index 84e5200..11b2ff8 100644 (file)
@@ -1525,7 +1525,7 @@ QList<QSslError> QSslSocketBackendPrivate::verify(QList<QSslCertificate> certifi
         }
     }
 
-    _q_sslErrorList()->mutex.lock();
+    QMutexLocker sslErrorListMutexLocker(&_q_sslErrorList()->mutex);
 
     // Register a custom callback to get all verification errors.
     X509_STORE_set_verify_cb_func(certStore, q_X509Callback);
@@ -1585,7 +1585,7 @@ QList<QSslError> QSslSocketBackendPrivate::verify(QList<QSslCertificate> certifi
     const QList<QPair<int, int> > errorList = _q_sslErrorList()->errors;
     _q_sslErrorList()->errors.clear();
 
-    _q_sslErrorList()->mutex.unlock();
+    sslErrorListMutexLocker.unlock();
 
     // Translate the errors
     if (QSslCertificatePrivate::isBlacklisted(certificateChain[0])) {