diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2017-09-04 18:23:56 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2017-12-14 18:15:50 +0000 |
commit | 00c09e752ff7e482e1308e0e34721dc979204595 (patch) | |
tree | 1eacb4b62d00aca5867c5cc605531443b74c1efc /src/corelib/itemmodels | |
parent | c87ed145f14b37a753b3b6c2fbfc7cfe4bda1a3c (diff) |
QAbstractItemModel: add more checks in begin{Insert,Remove}{Rows,Columns}
Check that the inserted/removed range is indeed valid.
Change-Id: Ifccbe13f0753252ee1450c8668df782dc699f05b
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/corelib/itemmodels')
-rw-r--r-- | src/corelib/itemmodels/qabstractitemmodel.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 44622a0ad9..7e1ab851d7 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -2686,6 +2686,7 @@ bool QAbstractItemModel::decodeData(int row, int column, const QModelIndex &pare void QAbstractItemModel::beginInsertRows(const QModelIndex &parent, int first, int last) { Q_ASSERT(first >= 0); + Q_ASSERT(first <= rowCount(parent)); // == is allowed, to insert at the end Q_ASSERT(last >= first); Q_D(QAbstractItemModel); d->changes.push(QAbstractItemModelPrivate::Change(parent, first, last)); @@ -2741,6 +2742,7 @@ void QAbstractItemModel::beginRemoveRows(const QModelIndex &parent, int first, i { Q_ASSERT(first >= 0); Q_ASSERT(last >= first); + Q_ASSERT(last < rowCount(parent)); Q_D(QAbstractItemModel); d->changes.push(QAbstractItemModelPrivate::Change(parent, first, last)); emit rowsAboutToBeRemoved(parent, first, last, QPrivateSignal()); @@ -2987,6 +2989,7 @@ void QAbstractItemModel::endMoveRows() void QAbstractItemModel::beginInsertColumns(const QModelIndex &parent, int first, int last) { Q_ASSERT(first >= 0); + Q_ASSERT(first <= columnCount(parent)); // == is allowed, to insert at the end Q_ASSERT(last >= first); Q_D(QAbstractItemModel); d->changes.push(QAbstractItemModelPrivate::Change(parent, first, last)); @@ -3043,6 +3046,7 @@ void QAbstractItemModel::beginRemoveColumns(const QModelIndex &parent, int first { Q_ASSERT(first >= 0); Q_ASSERT(last >= first); + Q_ASSERT(last < columnCount(parent)); Q_D(QAbstractItemModel); d->changes.push(QAbstractItemModelPrivate::Change(parent, first, last)); emit columnsAboutToBeRemoved(parent, first, last, QPrivateSignal()); |