summaryrefslogtreecommitdiffstats
path: root/src/widgets/graphicsview
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-05-29 10:24:31 +0200
committerLars Knoll <lars.knoll@qt.io>2020-05-29 23:21:51 +0200
commitf98fe1ba41002f936aa2fc3dac0f7b27fc290938 (patch)
tree0d6734f1ed1be8cc0d308307b15e75e80fabc928 /src/widgets/graphicsview
parentd4ff606941704ef2dd7520a0c81c982a5a0b0f73 (diff)
Fix UB in QGraphicsScene::wheelEvent()
operator--() would iterate before begin() if the list was empty. This is UB, and will crash in Qt 6, where begin()/end() can return an iterator pointing to a nullptr if the list is empty. Change-Id: I39c3a8ebb09fcad75d42019b02426ac5ac05eed9 Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/widgets/graphicsview')
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index d5ab1afd92..ba115b7485 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -4101,7 +4101,8 @@ void QGraphicsScene::wheelEvent(QGraphicsSceneWheelEvent *wheelEvent)
// Remove all popups after the one found, or all or them if no popup is under the mouse.
// Then continue with the event.
QList<QGraphicsWidget *>::const_iterator iter = d->popupWidgets.constEnd();
- while (--iter >= d->popupWidgets.constBegin() && !wheelCandidates.isEmpty()) {
+ while (iter > d->popupWidgets.constBegin() && !wheelCandidates.isEmpty()) {
+ --iter;
if (wheelCandidates.first() == *iter || (*iter)->isAncestorOf(wheelCandidates.first()))
break;
d->removePopup(*iter);