From eb447679456336d387bb69a56c164b06fbe83166 Mon Sep 17 00:00:00 2001 From: Kevin Funk Date: Thu, 28 Aug 2014 15:46:03 +0200 Subject: Fix crash in QTextLayout::cursorToX When 'cursorPos' is out of bounds ([0, lineEnd]), this method crashed. Change-Id: Ia0540ab3afbffb5c598f7b8515263cce3b3928e4 Task-number: QTBUG-40753 Reviewed-by: Dominik Haumann Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Konstantin Ritt --- src/gui/text/qtextlayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui/text/qtextlayout.cpp') diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 4879ae51d7..8e605e4ae1 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -2583,7 +2583,7 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const } int lineEnd = line.from + line.length + line.trailingSpaces; - int pos = *cursorPos; + int pos = qBound(0, *cursorPos, lineEnd); int itm; const QCharAttributes *attributes = eng->attributes(); if (!attributes) { -- cgit v1.2.3