summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qsharedpointer.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2025-06-06 20:32:16 +0200
committerMarc Mutz <marc.mutz@qt.io>2025-06-12 14:04:58 +0200
commit184d0bf2ec03dd3707b4b6326f6ba7e657afadc8 (patch)
tree21025c2f0e40001d1a88b6271ef649d4642ff71b /src/corelib/tools/qsharedpointer.cpp
parente4b0549a4c3f55828488fad6e6f5723072d6a291 (diff)
QSharedPointer: fix uninit'ed field 'destroyer'
The getAndRef(const QObject*) function failed to initialize ExternalRefCountData's destroyer field: the Qt::Uninitialized ctor doesn't init anything and there are no following assignments to the field, either. This probably a) caused some Coverty complaint (but I didn't check, because the Coverity UI is so clumsy) and b) was harmless, seeing as the -1 in strongref indicated that the destroyer is never to be fired. Fix it nevertheless by initializing it to nullptr. Amends the start of the public history. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: Ib76b4bc00b08289bb8d6d58096b43501b47814d1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qsharedpointer.cpp')
-rw-r--r--src/corelib/tools/qsharedpointer.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp
index 5899cd9a548..ad8a3789084 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -1541,6 +1541,7 @@ QtSharedPointer::ExternalRefCountData *QtSharedPointer::ExternalRefCountData::ge
ExternalRefCountData *x = ::new ExternalRefCountData(Qt::Uninitialized);
x->strongref.storeRelaxed(-1);
x->weakref.storeRelaxed(2); // the QWeakPointer that called us plus the QObject itself
+ x->destroyer = nullptr;
ExternalRefCountData *ret;
if (d->sharedRefcount.testAndSetOrdered(nullptr, x, ret)) { // ought to be release+acquire; this is acq_rel+acquire