diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-07-28 19:51:53 +0300 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-08-01 16:07:40 +0000 |
commit | 08f38d22149f062006316997a04fee57c33bc577 (patch) | |
tree | ab482bc833cf42cc8b6c2f997320fc1b8e4d6bdb /src | |
parent | a81be85b63f8caf817bb7c4a840ff3a3aaf49a83 (diff) |
tst_QAbstractItemView: Fix UB (invalid downcast, member call)
As reported by UBSan:
tst_qabstractitemview.cpp:336:23: runtime error: member call on address 0x7ffe6fe96e10 which does not point to an object of type 'TestView'
0x7ffe6fe96e10: note: object is of type 'QListView'
tst_qabstractitemview.cpp:337:5: runtime error: member call on address 0x7ffe6fe96e10 which does not point to an object of type 'TestView'
0x7ffe6fe96e10: note: object is of type 'QListView'
tst_qabstractitemview.cpp:338:23: runtime error: member call on address 0x7ffe6fe96e10 which does not point to an object of type 'TestView'
0x7ffe6fe96e10: note: object is of type 'QListView'
[etc ...]
Fix by making the test a friend of QAbstractItemView instead.
Change-Id: I1a08977042296eb34e9dbdb5c0595662dbd2e5ef
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/itemviews/qabstractitemview.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.h b/src/widgets/itemviews/qabstractitemview.h index ff1848b149..82bc7cb9ae 100644 --- a/src/widgets/itemviews/qabstractitemview.h +++ b/src/widgets/itemviews/qabstractitemview.h @@ -39,6 +39,8 @@ #include <QtCore/qitemselectionmodel.h> #include <QtWidgets/qabstractitemdelegate.h> +class tst_QAbstractItemView; + QT_BEGIN_NAMESPACE @@ -359,6 +361,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_scrollerStateChanged()) #endif + friend class ::tst_QAbstractItemView; friend class QTreeViewPrivate; // needed to compile with MSVC friend class QListModeViewBase; friend class QListViewPrivate; |