From b71c8eb3864f36ba7bafce1fcb7c7caee67f4405 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 23 Jul 2020 16:59:22 +0200 Subject: QCompleter: fix an out of bounds access in a QMap If the iterator points to the map's begin(), then one can't decrement it. Split the check and the decrement. Change-Id: I3d816f13d0bcacc8253ba6d223bc83c874e5efb5 Pick-to: 5.15 Reviewed-by: Volker Hilsheimer Reviewed-by: Edward Welbourne --- src/widgets/util/qcompleter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index 7febc23b2d..b3833c5f50 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -587,7 +587,8 @@ QIndexMapper QSortedModelEngine::indexHint(QString part, const QModelIndex& pare const CacheItem::const_iterator it = map.lowerBound(part); // look backward for first valid hint - for(CacheItem::const_iterator it1 = it; it1-- != map.constBegin();) { + for (CacheItem::const_iterator it1 = it; it1 != map.constBegin();) { + --it1; const QMatchData& value = it1.value(); if (value.isValid()) { if (order == Qt::AscendingOrder) { -- cgit v1.2.3