Fix a crash in the woff2 encoder when it encounters a loca table with a length of zero.

This commit is contained in:
Garret Rieger
2017-07-19 17:35:13 -07:00
parent 4f659ddbad
commit 849bdb0d24
+5 -2
View File
@@ -331,8 +331,11 @@ int NumGlyphs(const Font& font) {
return 0; return 0;
} }
int index_fmt = IndexFormat(font); int index_fmt = IndexFormat(font);
int num_glyphs = (loca_table->length / (index_fmt == 0 ? 2 : 4)) - 1; int loca_record_size = (index_fmt == 0 ? 2 : 4);
return num_glyphs; if (loca_table->length < loca_record_size) {
return 0;
}
return (loca_table->length / loca_record_size) - 1;
} }
int IndexFormat(const Font& font) { int IndexFormat(const Font& font) {