From 7aa0adf130447214ff3a7bb8144d35b366e94d77 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 29 Oct 2012 12:03:34 +0200 Subject: QFontEngineMulti: Fix possible crash in stringToCMap() in case when the layout is partially initialized. We shouldn't access any data except of indices if GlyphIndicesOnly flag has been passed in. Change-Id: I264689b498e0f9de8b5c040d47dbae4f6ef391c4 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontengine.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/gui/text') diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index bdcf166243..fa4e7a75bc 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1370,7 +1370,9 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len, bool surrogate = (str[i].isHighSurrogate() && i < len-1 && str[i+1].isLowSurrogate()); uint ucs4 = surrogate ? QChar::surrogateToUcs4(str[i], str[i+1]) : str[i].unicode(); if (glyphs->glyphs[glyph_pos] == 0 && str[i].category() != QChar::Separator_Line) { - QGlyphLayoutInstance tmp = glyphs->instance(glyph_pos); + QGlyphLayoutInstance tmp; + if (!(flags & GlyphIndicesOnly)) + tmp = glyphs->instance(glyph_pos); for (int x=1; x < engines.size(); ++x) { if (engines.at(x) == 0 && !shouldLoadFontEngineForCharacter(x, ucs4)) continue; @@ -1400,9 +1402,8 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len, } // ensure we use metrics from the 1st font when we use the fallback image. - if (!glyphs->glyphs[glyph_pos]) { + if (!(flags & GlyphIndicesOnly) && !glyphs->glyphs[glyph_pos]) glyphs->setInstance(glyph_pos, tmp); - } } if (surrogate) -- cgit v1.2.3