From b8802071ed00689373da5817fc4824a30b5fcf86 Mon Sep 17 00:00:00 2001 From: ChunLin Wang Date: Wed, 31 Mar 2021 17:54:49 +0800 Subject: Fix get out of bounds index in QSortFilterProxyModel::filterAcceptsRow Before calling the index function, we need to check the validity of the parameters. Fixes: QTBUG-91878 Pick-to: 5.15 6.0 6.1 Change-Id: I9ec7265fff3f81b8a288c4ba8fae606a2ec808a6 Reviewed-by: David Faure --- .../tst_qconcatenatetablesproxymodel.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp index e1ea7a4552..90972caa57 100644 --- a/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp @@ -117,6 +117,7 @@ private Q_SLOTS: void shouldPropagateDropAfterLastRow_data(); void shouldPropagateDropAfterLastRow(); void qtbug91788(); + void qtbug91878(); private: QStandardItemModel mod; @@ -843,6 +844,22 @@ void tst_QConcatenateTablesProxyModel::qtbug91788() QCOMPARE(proxyConcat.columnCount(), 0); } +void tst_QConcatenateTablesProxyModel::qtbug91878() +{ + QStandardItemModel m; + m.setRowCount(4); + m.setColumnCount(4); + + QConcatenateTablesProxyModel pm; + QSortFilterProxyModel proxyFilter; + proxyFilter.setSourceModel(&pm); + proxyFilter.setFilterFixedString("something"); + pm.addSourceModel(&m); // This should not assert + + QCOMPARE(pm.columnCount(), 4); + QCOMPARE(pm.rowCount(), 4); +} + QTEST_GUILESS_MAIN(tst_QConcatenateTablesProxyModel) #include "tst_qconcatenatetablesproxymodel.moc" -- cgit v1.2.3