diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2022-01-13 09:13:48 +0100 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2022-01-14 18:57:41 +0100 |
commit | 413cd06c88d4ccc5e1383d5f1f556fd35333dcbc (patch) | |
tree | 066b7c695d234a3e5c8ea53ef921146617e7ca10 /src/gui | |
parent | 3ed7a5a963b89554de9ebdb025c2783b4cee8177 (diff) |
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>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/text/qtextengine.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 14e44f56d9..9e294d083e 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -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; } |