Fix crash when text shaping fails

If text shaping failed for some reason (for example if the
string passed to Harfbuzz contains ignorables only), we
would return a single glyph for the whole string. But we
forgot to initialize the log clusters array, which could
cause crashes later when this was read. We initialize a
single cluster consisting of the "missing glyph" glyph to
be consistent.

Amends fccd419dd632306a4bd85928223e0a56a59510ef.

[ChangeLog][QtGui][Text] Fixed a possible crash with certain fonts
when shaping strings consisting only of control characters.

Pick-to: 5.15 6.2 6.3
Task-number: QTBUG-89155
Fixes: QTBUG-92358
Change-Id: I1ec0237d99b48be2a8bb340f0feb056bca4fdffe
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2022-01-13 09:13:48 +01:00
parent 3ed7a5a963
commit 413cd06c88

View File

@ -1564,6 +1564,12 @@ void QTextEngine::shapeText(int item) const
// Overwrite with 0 token to indicate failure
QGlyphLayout g = availableGlyphs(&si);
g.glyphs[0] = 0;
g.attributes[0].clusterStart = true;
ushort *log_clusters = logClusters(&si);
for (int i = 0; i < itemLength; ++i)
log_clusters[i] = 0;
return;
}