Repository navigation
Commit 80ddc8d
committed
Fix crash when fontconfig fallback pattern has no charset
QFontEngineMultiFontConfig::shouldLoadFontEngineForCharacter() passed
the address of an uninitialized FcCharSet* to FcPatternGetCharSet()
and then called FcCharSetHasChar() on it without checking the result.
A pattern returned by FcFontMatch() is not guaranteed to carry an
FC_CHARSET element: fontconfig treats the charset as optional, and
caches produced by other fontconfig builds (e.g. a bundled snapshot
that indexed .woff/.woff2 files it could not parse as empty patterns)
can legally serve charset-less patterns. In that case the uninitialized
pointer is dereferenced inside FcCharSetHasChar() and the process
crashes with SIGSEGV; builds hardened with
-ftrivial-auto-var-init=pattern crash deterministically at 0xfefe...
Observed in the wild on Arch/Manjaro after the fontconfig 2.18.1
upgrade: every Qt application (Qt Creator, CopyQ, KeePassXC, ...)
crashed in FcCharSetHasChar via QFontEngineMulti::glyphIndex() as soon
as any glyph fallback lookup ran, because stale fontconfig caches
served a charset-less pattern for every FcFontMatch() call.
Initialize the pointer and check the FcPatternGetCharSet() result.
When no charset can be obtained, keep the optimistic default (load the
engine) exactly as we already do when no match pattern is available,
so glyph coverage is decided by the font engine itself.
Pick-to: 6.12 6.11 6.8
Change-Id: I18687e0a7b7a0019a459155395636768ad9ea964
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>1 parent bd7909f commit 80ddc8d
1 file changed
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
0 commit comments