SSL internals: certificate verification: use mutex locker

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
This commit is contained in:
Peter Hartmann 2011-07-14 11:28:32 +02:00 committed by Qt by Nokia
parent 3b19eab45e
commit 6ab8ecb002

View 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. // Register a custom callback to get all verification errors.
X509_STORE_set_verify_cb_func(certStore, q_X509Callback); 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; const QList<QPair<int, int> > errorList = _q_sslErrorList()->errors;
_q_sslErrorList()->errors.clear(); _q_sslErrorList()->errors.clear();
_q_sslErrorList()->mutex.unlock(); sslErrorListMutexLocker.unlock();
// Translate the errors // Translate the errors
if (QSslCertificatePrivate::isBlacklisted(certificateChain[0])) { if (QSslCertificatePrivate::isBlacklisted(certificateChain[0])) {