summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs/qfilesystemmodel.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-08-29 09:02:31 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-12-05 09:05:38 +0000
commit77687bc64e9ae7172586271de91b266be7ab19ce (patch)
treeaf9a3db1a358a5b6c177e2f38da976811424c7b5 /src/widgets/dialogs/qfilesystemmodel.cpp
parentb8a6e2b6e8e4b5ea0734285f485c03c22022c30e (diff)
QFileSystemModel::index(): Add a list size check
This prevents an out of range assert when monitoring directory with activity (for example, temp). Task-number: QTBUG-62841 Change-Id: Id3aa4098e9bbd665c7b17a667516885fa7c7f473 Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io> Reviewed-by: Martin Rotter <rotter.martinos@gmail.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/dialogs/qfilesystemmodel.cpp')
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index bf14b5c6fd..179c5861c9 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -260,7 +260,10 @@ QModelIndex QFileSystemModel::index(int row, int column, const QModelIndex &pare
Q_ASSERT(parentNode);
// now get the internal pointer for the index
- const QString &childName = parentNode->visibleChildren.at(d->translateVisibleLocation(parentNode, row));
+ const int i = d->translateVisibleLocation(parentNode, row);
+ if (i >= parentNode->visibleChildren.size())
+ return QModelIndex();
+ const QString &childName = parentNode->visibleChildren.at(i);
const QFileSystemModelPrivate::QFileSystemNode *indexNode = parentNode->children.value(childName);
Q_ASSERT(indexNode);