From 8b310f917a5baa7ffb496f9f06928cb9dc259949 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 28 Feb 2024 10:37:36 +0100 Subject: [PATCH] Fix crash rendering emoji on macOS with FontCollection that lacks default font manager FontCollection checks if fDefaultFontManager is non-null in various places before using it, except when determining the emoji fallback font. This can cause a crash when the FontCollection was not initialized with a default font manager. --- modules/skparagraph/src/FontCollection.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/skparagraph/src/FontCollection.cpp b/modules/skparagraph/src/FontCollection.cpp index df69143205a7..ab7047ae02e9 100644 --- a/modules/skparagraph/src/FontCollection.cpp +++ b/modules/skparagraph/src/FontCollection.cpp @@ -176,10 +176,12 @@ sk_sp FontCollection::defaultEmojiFallback(SkUnichar emojiStart, for (const auto& manager : this->getFontManagerOrder()) { std::vector bcp47; #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) - sk_sp emojiTypeface = - fDefaultFontManager->matchFamilyStyle(kColorEmojiFontMac, SkFontStyle()); - if (emojiTypeface != nullptr) { - return emojiTypeface; + if (fDefaultFontManager) { + sk_sp emojiTypeface = + fDefaultFontManager->matchFamilyStyle(kColorEmojiFontMac, SkFontStyle()); + if (emojiTypeface != nullptr) { + return emojiTypeface; + } } #else bcp47.push_back(kColorEmojiLocale);