From 29eb45e667be81d37f29fcce2adccb8c5e6d5ada Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 11 Jul 2014 11:30:06 -0400 Subject: [PATCH] Don't pass invalid Unicode codepoint to Skia Bug: 15849380 Change-Id: Ib5285e57c5806bd399600fadd56e8bc809da323f --- engine/src/flutter/libs/minikin/Layout.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/engine/src/flutter/libs/minikin/Layout.cpp b/engine/src/flutter/libs/minikin/Layout.cpp index 01b6599628..21b8362260 100644 --- a/engine/src/flutter/libs/minikin/Layout.cpp +++ b/engine/src/flutter/libs/minikin/Layout.cpp @@ -258,6 +258,12 @@ static hb_bool_t harfbuzzGetGlyph(hb_font_t* hbFont, void* fontData, hb_codepoin MinikinPaint* paint = reinterpret_cast(fontData); MinikinFont* font = paint->font; uint32_t glyph_id; + /* HarfBuzz replaces broken input codepoints with (unsigned int) -1. + * Skia expects valid Unicode. + * Replace invalid codepoints with U+FFFD REPLACEMENT CHARACTER. + */ + if (unicode > 0x10FFFF) + unicode = 0xFFFD; bool ok = font->GetGlyph(unicode, &glyph_id); if (ok) { *glyph = glyph_id;