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 <volker.hilsheimer@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Giuseppe D'Angelo 2020-07-23 16:59:22 +02:00
parent a77c159044
commit b71c8eb386

View File

@ -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) {