diff options
author | Joerg Bornemann <joerg.bornemann@digia.com> | 2014-10-22 18:06:36 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@theqtcompany.com> | 2014-10-27 10:01:28 +0100 |
commit | c803af51677c31ec7010f5c481ad59272694f138 (patch) | |
tree | 17b63c28a945a3b61c2cb115ee934761dfb66862 /src/gui/text/qtextlayout.cpp | |
parent | 309e82021de1b49753559086592749d9fe02b239 (diff) |
fix crash when dropping a file into an empty QTextEdit
Since commit be0bfe09ee4b99e9ab45c6898949b5d144e77a29 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>
Diffstat (limited to 'src/gui/text/qtextlayout.cpp')
-rw-r--r-- | src/gui/text/qtextlayout.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index adc5663299..911d1b8bc7 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -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]; |