From 5dc83974f7e6f72d715c4c940ca57741a550aa1c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 28 Jul 2016 19:51:53 +0300 Subject: tst_QTreeView: Fix UB (invalid downcast, member call) As reported by UBSan: tst_qtreeview.cpp:2187:36: runtime error: downcast of address 0x7ffc15749f20 which does not point to an object of type 'PublicView' 0x7ffc15749f20: note: object is of type 'QTreeView' Fix by making the test a friend of QTreeView (and, for Clang, of QAbstractItemView) instead. Change-Id: I5b748696ab441a91058f4d45a18bd5ed75a6e560 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/itemviews/qabstractitemview.h | 2 ++ src/widgets/itemviews/qtreeview.h | 3 +++ 2 files changed, 5 insertions(+) (limited to 'src') diff --git a/src/widgets/itemviews/qabstractitemview.h b/src/widgets/itemviews/qabstractitemview.h index 82bc7cb9ae..8d712280d3 100644 --- a/src/widgets/itemviews/qabstractitemview.h +++ b/src/widgets/itemviews/qabstractitemview.h @@ -40,6 +40,7 @@ #include class tst_QAbstractItemView; +class tst_QTreeView; QT_BEGIN_NAMESPACE @@ -362,6 +363,7 @@ private: #endif friend class ::tst_QAbstractItemView; + friend class ::tst_QTreeView; friend class QTreeViewPrivate; // needed to compile with MSVC friend class QListModeViewBase; friend class QListViewPrivate; diff --git a/src/widgets/itemviews/qtreeview.h b/src/widgets/itemviews/qtreeview.h index 546cc488cb..9257bb66fa 100644 --- a/src/widgets/itemviews/qtreeview.h +++ b/src/widgets/itemviews/qtreeview.h @@ -36,6 +36,8 @@ #include +class tst_QTreeView; + QT_BEGIN_NAMESPACE @@ -213,6 +215,7 @@ protected: void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) Q_DECL_OVERRIDE; private: + friend class ::tst_QTreeView; friend class QAccessibleTable; friend class QAccessibleTree; friend class QAccessibleTableCell; -- cgit v1.2.3