2010-11-29 Jan Erik Hanssen <jhanssen@sencha.com>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Nov 2010 12:05:56 +0000 (12:05 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Nov 2010 12:05:56 +0000 (12:05 +0000)
        Reviewed by Kenneth Rohde Christiansen.

        QtWebKit asserts when selecting elided text.
        https://bugs.webkit.org/show_bug.cgi?id=45391

        Ensure that the length passed to fromRawDataWithoutRef() does
        not exceed the length of the string.

        * platform/graphics/qt/FontQt.cpp:
        (WebCore::Font::selectionRectForSimpleText):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@72788 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/graphics/qt/FontQt.cpp

index 2f680cf..8f38852 100644 (file)
@@ -1,3 +1,16 @@
+2010-11-29  Jan Erik Hanssen  <jhanssen@sencha.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        QtWebKit asserts when selecting elided text.
+        https://bugs.webkit.org/show_bug.cgi?id=45391
+
+        Ensure that the length passed to fromRawDataWithoutRef() does
+        not exceed the length of the string.
+
+        * platform/graphics/qt/FontQt.cpp:
+        (WebCore::Font::selectionRectForSimpleText):
+
 2010-11-26  Alexander Pavlov  <apavlov@chromium.org>
 
         Reviewed by Pavel Feldman.
index 564ab2b..89dfd00 100644 (file)
@@ -344,7 +344,7 @@ FloatRect Font::selectionRectForSimpleText(const TextRun& run, const FloatPoint&
 #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
     String sanitized = Font::normalizeSpaces(String(run.characters(), run.length()));
     QString wholeText = fromRawDataWithoutRef(sanitized);
-    QString selectedText = fromRawDataWithoutRef(sanitized, from, to - from);
+    QString selectedText = fromRawDataWithoutRef(sanitized, from, qMin(to - from, wholeText.length() - from));
 
     int startX = QFontMetrics(font()).width(wholeText, from, Qt::TextBypassShaping);
     int width = QFontMetrics(font()).width(selectedText, -1, Qt::TextBypassShaping);