diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2022-01-27 09:47:59 +0100 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2022-02-01 14:32:57 +0100 |
commit | 33ad8b6fa9afbe4b8612f26c0bad42d23d94e7b2 (patch) | |
tree | f8d5333f38148321f353f1fe2dcbaf7715717975 /src/widgets/itemviews/qabstractitemview.cpp | |
parent | 22ac61e62a1a65bf0049229ab6fcaa44e8688951 (diff) |
QAbstractItemView: do not access invalid model indices (1/N)
Calling selectAll() on a view with an empty model, with the view
in ContiguousSelection, causes an out of bounds access into the model.
Guard the access.
Change-Id: I3830a979bad760e9e1526c1c8b12d9767d41fc99
Pick-to: 5.15 6.2 6.3
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/widgets/itemviews/qabstractitemview.cpp')
-rw-r--r-- | src/widgets/itemviews/qabstractitemview.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 9727ddf3d9..d9a64a3544 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -1213,7 +1213,8 @@ void QAbstractItemView::selectAll() break; case NoSelection: case ContiguousSelection: - d->selectAll(selectionCommand(d->model->index(0, 0, d->root))); + if (d->model->hasChildren(d->root)) + d->selectAll(selectionCommand(d->model->index(0, 0, d->root))); break; case SingleSelection: break; |