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.9 6.8 6.5 Change-Id: Ib76b4bc00b08289bb8d6d58096b43501b47814d1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 184d0bf2ec03dd3707b4b6326f6ba7e657afadc8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
6b77b43b1a
commit
d6fb65adb0
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user