From e6c5e03d616e361d2340ea652245cac6f63f1ce7 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 6 Jun 2025 16:40:48 +0200 Subject: [PATCH] QEventLoop: fix potential UB in QBasicAtomic initialization Until C++17 (inclusive), a default-constructed std::atomic object can, officially, only be initialized with a call to std::atomic_init, for which QBasicAtomic doesn't have API. It is even unclear whether zero-initialization of static and thread-local objects will cause the object to be initialized. To fix, port from QBasicAtomic to QAtomic (which initializes to zero). Task-number: QTBUG-137465 Pick-to: 6.8 6.5 Change-Id: I31a95b36506c376ef0817ef3d61bd8ca02371585 Reviewed-by: Thiago Macieira (cherry picked from commit 8f4ffb72f9e49702f878222b785cf0efc871ee9c) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 2d55125018a24a19dc07e317c06179dd083e8694) --- src/corelib/kernel/qeventloop_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qeventloop_p.h b/src/corelib/kernel/qeventloop_p.h index 1461188e9fd..aa50b8c1d3d 100644 --- a/src/corelib/kernel/qeventloop_p.h +++ b/src/corelib/kernel/qeventloop_p.h @@ -34,8 +34,8 @@ public: QAtomicInt quitLockRef; - QBasicAtomicInt exit; // bool - QBasicAtomicInt returnCode; + QAtomicInt exit; // bool + QAtomicInt returnCode; bool inExec; void ref()