qt5base-lts/tests/auto/corelib
Marc Mutz f5291bf8b4 Fix UB in tst_QObject::noDeclarativeParentChangedOnDestruction()
If QObjectPrivate::declarativeData is set, it is
in various places in Qt expected to point to a
QAbstractDeclarativeDataImpl, from which ownedByQml1
is unconditionally read.

In noDeclarativeParentChangedOnDestruction(), the
declarativeData pointer is, however, set to a local
QAbstractDeclarativeData instance, which, being an
empty class, has size 1 and alignment 1.

Depending on the compiler's idea of bit field order,
this code either read uninitialized data from the
dummy object, or else some random stack memory outside
any (valid) object.

What caught UBSan's attention, though, was the
difference in alignment between the two classes:

  src/corelib/kernel/qobject.cpp:917:9: runtime error: member access within misaligned address 0x7fffc9cf706f for type 'struct QAbstractDeclarativeDataImpl', which requires 4 byte alignment

Fix by providing a properly initialized object of the
correct type.

Change-Id: Iae83a949ee5a7bc98df13e35ea614c063085fa13
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-01-07 13:00:28 +00:00
..
animation Update copyright headers 2015-02-11 06:49:51 +00:00
codecs Fix utf8->utf16 BOM/ZWNBSP decoding. 2015-12-21 09:56:49 +00:00
global Disable thread-safe statics for MSVC 2015: they're broken 2015-07-16 08:28:07 +00:00
io Fix UB in tst_QIODevice::getSetCheck() 2016-01-06 17:25:05 +00:00
itemmodels Fix less-than comparison for QStandardItem and QSortFilterProxyModel with invalid data. 2015-06-11 13:29:23 +00:00
json Make sure remove() doesn't corrupt the json object 2015-03-18 07:34:59 +00:00
kernel Fix UB in tst_QObject::noDeclarativeParentChangedOnDestruction() 2016-01-07 13:00:28 +00:00
mimetypes QMimeDatabase: warn instead of asserting on bad magic. 2015-09-04 20:00:22 +00:00
plugin fix usage of wince scope 2015-06-05 10:29:10 +00:00
statemachine QStateMachine: fix ignore high-priority events. 2016-01-05 10:05:40 +00:00
thread Use qthread_win.cpp for WinRT as well 2015-06-23 05:47:14 +00:00
tools Fix comparisons between QByteArray and QString. 2015-09-28 07:42:51 +00:00
xml Update copyright headers 2015-02-11 06:49:51 +00:00
corelib.pro iOS: Enable building of basic tests 2014-01-22 12:35:17 +01:00