Sophie

Sophie

distrib > Mageia > 2 > x86_64 > media > core-release-src > by-pkgid > 71f52a1caad5b55830cde47f6d0a5a37 > files > 10

qt4-4.8.1-2.mga2.src.rpm

Fix a crash in cursorToX() when new block is added

When an empty new block is being added, the layoutData->memory data
will be 0, thus QTextEngine::attributes() will return 0. We should
only access the attributes pointer when some text actually exist.

Task-number: QTBUG-24718
Change-Id: I9ce9f7b57bccf24099a02832ce30fb6cebfaad33
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -2501,20 +2501,24 @@
     x += eng->alignLine(line);
 
     if (!i && !eng->layoutData->items.size()) {
         *cursorPos = 0;
         return x.toReal();
     }
 
     int pos = *cursorPos;
     int itm;
     const HB_CharAttributes *attributes = eng->attributes();
+    if (!attributes) {
+        *cursorPos = 0;
+        return x.toReal();
+    }
     while (pos < line.from + line.length && !attributes[pos].charStop)
         pos++;
     if (pos == line.from + (int)line.length) {
         // end of line ensure we have the last item on the line
         itm = eng->findItem(pos-1);
     }
     else
         itm = eng->findItem(pos);
     eng->shapeLine(line);