From e28a957035878abc5e7cccc9d16ffe0fcad842a2 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 5 Sep 2012 20:42:28 +0200 Subject: Fix crash when QTextLayout::setAdditionalFormats is called with ranges with negative length That can be reproduced in Qt Creator when deleting code. Task-number: QTBUG-27140 Change-Id: Ida7177612653f10e5d866bf9a422c71c632f4eb3 Reviewed-by: Simon Hausmann --- src/gui/text/qtextengine.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/gui/text') diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 448907b4fe..a07c562aca 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2723,8 +2723,10 @@ void QTextEngine::resolveAdditionalFormats() const QVarLengthArray addFormatSortedByStart; addFormatSortedByStart.reserve(specialData->addFormats.count()); - for (int i = 0; i < specialData->addFormats.count(); ++i) - addFormatSortedByStart.append(i); + for (int i = 0; i < specialData->addFormats.count(); ++i) { + if (specialData->addFormats.at(i).length >= 0) + addFormatSortedByStart.append(i); + } QVarLengthArray addFormatSortedByEnd = addFormatSortedByStart; qSort(addFormatSortedByStart.begin(), addFormatSortedByStart.end(), FormatRangeComparatorByStart(specialData->addFormats)); -- cgit v1.2.3