Fix possible assertion when using stringToCMap() for a multi engine
authorKonstantin Ritt <ritt.ks@gmail.com>
Fri, 16 Nov 2012 19:07:26 +0000 (21:07 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 27 Nov 2012 15:06:05 +0000 (16:06 +0100)
If (*nglyphs < len), stringToCMap() sets *nglyphs to len and returns
false immediately; the caller then must resize the buffer and re-try.
However, QFontEngineMulti::stringToCMap() doesn't update the nglyphs value
and thus the second call would fail, too. This is quite unexpected.

Change-Id: Id2cce7b9faf7706c382fccf023e1b7affa9a10be
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
src/gui/text/qfontengine.cpp

index 400ce83..0f0ad29 100644 (file)
@@ -1364,8 +1364,7 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len,
                                     QGlyphLayout *glyphs, int *nglyphs,
                                     QFontEngine::ShaperFlags flags) const
 {
-    int ng = *nglyphs;
-    if (!engine(0)->stringToCMap(str, len, glyphs, &ng, flags))
+    if (!engine(0)->stringToCMap(str, len, glyphs, nglyphs, flags))
         return false;
 
     const_cast<QFontEngineMulti *>(this)->ensureFallbackFamiliesQueried();
@@ -1415,8 +1414,8 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len,
         ++glyph_pos;
     }
 
-    *nglyphs = ng;
-    glyphs->numGlyphs = ng;
+    *nglyphs = glyph_pos;
+    glyphs->numGlyphs = glyph_pos;
 
     return true;
 }