diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-02-23 21:23:49 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-03-07 18:36:15 +0000 |
commit | 80693f171c9e904007137f109a83fb456c9cae48 (patch) | |
tree | 2fb59271b89824ae33e84cadb400e333226b736f /src/gui/itemmodels | |
parent | b64f3f6ca97e299176ca8990402650552a90f704 (diff) |
QStandardItem: add more sanity checks on insertRow(s)/Column(s)
When QStandardItem::insertRows/Columns is called with an empty list
or an insert count of 0, do not assert but return false.
Task-number: QTBUG-66491
Change-Id: I328598e08584fb9b0a35075458bfeb31c57ebfee
Reviewed-by: Samuel Gaist <samuel.gaist@edeltech.ch>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/gui/itemmodels')
-rw-r--r-- | src/gui/itemmodels/qstandarditemmodel.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index d1e0604caf..050c9a662b 100644 --- a/src/gui/itemmodels/qstandarditemmodel.cpp +++ b/src/gui/itemmodels/qstandarditemmodel.cpp @@ -455,7 +455,7 @@ void QStandardItemModelPrivate::_q_emitItemChanged(const QModelIndex &topLeft, bool QStandardItemPrivate::insertRows(int row, const QList<QStandardItem*> &items) { Q_Q(QStandardItem); - if ((row < 0) || (row > rowCount())) + if ((row < 0) || (row > rowCount()) || items.isEmpty()) return false; int count = items.count(); if (model) @@ -486,7 +486,7 @@ bool QStandardItemPrivate::insertRows(int row, const QList<QStandardItem*> &item bool QStandardItemPrivate::insertRows(int row, int count, const QList<QStandardItem*> &items) { Q_Q(QStandardItem); - if ((count < 1) || (row < 0) || (row > rowCount())) + if ((count < 1) || (row < 0) || (row > rowCount()) || count == 0) return false; if (model) model->d_func()->rowsAboutToBeInserted(q, row, row + count - 1); @@ -528,7 +528,7 @@ bool QStandardItemPrivate::insertRows(int row, int count, const QList<QStandardI bool QStandardItemPrivate::insertColumns(int column, int count, const QList<QStandardItem*> &items) { Q_Q(QStandardItem); - if ((count < 1) || (column < 0) || (column > columnCount())) + if ((count < 1) || (column < 0) || (column > columnCount()) || count == 0) return false; if (model) model->d_func()->columnsAboutToBeInserted(q, column, column + count - 1); |