Add a nullptr check to GlyphTable::Glyph().
Do not attempt to create a new Glyph if there is no data.
Fixes https://crbug.com/641330
diff --git a/cpp/src/sfntly/table/truetype/glyph_table.cc b/cpp/src/sfntly/table/truetype/glyph_table.cc
index f38fac5..0c1e841 100644
--- a/cpp/src/sfntly/table/truetype/glyph_table.cc
+++ b/cpp/src/sfntly/table/truetype/glyph_table.cc
@@ -215,10 +215,11 @@
ReadableFontDataPtr sliced_data;
sliced_data.Attach(down_cast<ReadableFontData*>(data->Slice(offset, length)));
- if (type == GlyphType::kSimple) {
- glyph = new SimpleGlyph(sliced_data);
- } else {
- glyph = new CompositeGlyph(sliced_data);
+ if (sliced_data) {
+ if (type == GlyphType::kSimple)
+ glyph = new SimpleGlyph(sliced_data);
+ else
+ glyph = new CompositeGlyph(sliced_data);
}
return glyph.Detach();
}