fix crash when dropping a file into an empty QTextEdit

Since commit be0bfe09ee we return -1 in
QTextEngine::findItem if the item cannot be found.
Calling code must be prepared for this case.
Otherwise we run into an out-of-bounds vector access later on.

Task-number: QTBUG-42103
Change-Id: Ie338cd1fc3cf0ce1e8edfa59dead635669020a33
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
This commit is contained in:
Joerg Bornemann 2014-10-22 18:06:36 +02:00 committed by Joerg Bornemann
parent 309e82021d
commit c803af5167

View File

@ -2559,6 +2559,10 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const
}
else
itm = eng->findItem(pos);
if (itm < 0) {
*cursorPos = 0;
return x.toReal();
}
eng->shapeLine(line);
const QScriptItem *si = &eng->layoutData->items[itm];