Skip to content

Commit

Permalink
[Skia] Crash when failing to create a font with custom data
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=271391

Reviewed by Adrian Perez de Castro.

This happens for example with test
fast/css/font-face-data-uri-invalid.html. SkFontMgr::makeFromData()
fails to create the SkTypeface and returns nullptr that we don't check.

* Source/WebCore/platform/graphics/skia/FontCustomPlatformDataSkia.cpp:
(WebCore::FontCustomPlatformData::create):

Canonical link: https://commits.webkit.org/276473@main
  • Loading branch information
carlosgcampos committed Mar 21, 2024
1 parent 501aaeb commit d0d7718
Showing 1 changed file with 3 additions and 0 deletions.
Expand Up @@ -102,6 +102,9 @@ FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription&
RefPtr<FontCustomPlatformData> FontCustomPlatformData::create(SharedBuffer& buffer, const String& itemInCollection)
{
sk_sp<SkTypeface> typeface = FontCache::forCurrentThread().fontManager()->makeFromData(buffer.createSkData());
if (!typeface)
return nullptr;

FontPlatformData::CreationData creationData = { buffer, itemInCollection };
return adoptRef(new FontCustomPlatformData(WTFMove(typeface), WTFMove(creationData)));
}
Expand Down

0 comments on commit d0d7718

Please sign in to comment.