From 80693f171c9e904007137f109a83fb456c9cae48 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 23 Feb 2018 21:23:49 +0100 Subject: 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 Reviewed-by: Richard Moe Gustavsen --- src/gui/itemmodels/qstandarditemmodel.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gui/itemmodels') 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 &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 &item bool QStandardItemPrivate::insertRows(int row, int count, const QList &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 &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); -- cgit v1.2.3