From 7a8bd97226581278ad458d2737c5d9e39abbe046 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sat, 3 Aug 2024 14:54:49 +0200 Subject: [PATCH] Added a precaution to prevent crashes in case of broken fonts being used --- es-core/src/resources/Font.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/es-core/src/resources/Font.cpp b/es-core/src/resources/Font.cpp index c04531ffb..a3a426550 100644 --- a/es-core/src/resources/Font.cpp +++ b/es-core/src/resources/Font.cpp @@ -760,6 +760,9 @@ std::vector Font::shapeText(const std::string& text) lastCursor = textCursor; const unsigned int unicode {Utils::String::chars2Unicode(text, textCursor)}; Glyph* currGlyph {getGlyph(unicode)}; + // Extra precaution in case the font is really broken. + if (currGlyph == nullptr) + continue; byteLength = textCursor - lastCursor; if (unicode == '\'' || unicode == '\n' || currGlyph->fontHB == nullptr) {