From 57a7db746aa16b28479738cde668ad3ab0f468b8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 19 Mar 2023 15:30:02 +0100 Subject: [PATCH] QMessageAuthenticationCode: reuse messageHash mutex QMessageAuthenticationCode operates the embedded QCryptographicHash in an unshared way, in which QCryptographicHashPrivate::finalizeMutex is never used. So kick QMessageAuthenticationCodePrivate::finalizeMutex out and use QCryptographicHashPrivate::finalizeMutex instead. The only effect it the reduction in QMessageAuthenticationCodePrivate size by sizeof(QBasicMutex). Pick-to: 6.5 Change-Id: I02208eb42f8247939619f74ad3e040cb0d34b5ba Reviewed-by: Thiago Macieira --- src/corelib/tools/qcryptographichash.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp index 07dc98a19c9..abfef79cec3 100644 --- a/src/corelib/tools/qcryptographichash.cpp +++ b/src/corelib/tools/qcryptographichash.cpp @@ -1309,7 +1309,6 @@ public: HashBlock key; HashResult result; - QBasicMutex finalizeMutex; QCryptographicHashPrivate messageHash; const QCryptographicHash::Algorithm method; @@ -1318,7 +1317,7 @@ public: void finalize(); // when not called from the static hash() function, this function needs to be - // called with finalizeMutex held: + // called with messageHash.finalizeMutex held: void finalizeUnchecked() noexcept; // END functions that need to be called with finalizeMutex held }; @@ -1571,7 +1570,7 @@ QByteArray QMessageAuthenticationCode::result() const void QMessageAuthenticationCodePrivate::finalize() { - const auto lock = qt_scoped_lock(finalizeMutex); + const auto lock = qt_scoped_lock(messageHash.finalizeMutex); if (!result.isEmpty()) return; finalizeUnchecked();