summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-05-13 18:21:01 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-05-17 16:49:31 +0000
commit0ca2cf42e0de422634f13fb6a5e5a9d7560b323b (patch)
tree72068620dc25dae530000e1cefc87d31b589b94e /src
parentff053b39a3083813f89b1a3b6e735c047c09890f (diff)
QReadWriteLock: fix another data race in stateForWaitCondition()
The writerCount member variable is only ever accessed under Private::mutex protection, so we need to lock the mutex here, too. Pick-to: 6.3 6.2 5.15 Change-Id: I1717e5282eed2ecc14ccdc5090b9fc41174cccc8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/thread/qreadwritelock.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/corelib/thread/qreadwritelock.cpp b/src/corelib/thread/qreadwritelock.cpp
index c60580b9f3..c31782d684 100644
--- a/src/corelib/thread/qreadwritelock.cpp
+++ b/src/corelib/thread/qreadwritelock.cpp
@@ -422,6 +422,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
if (!d)
return Unlocked;
+ const auto lock = qt_scoped_lock(d->mutex);
if (d->writerCount > 1)
return RecursivelyLocked;
else if (d->writerCount == 1)