Fix a crash in the woff2 encoder when it encounters a loca table with a length of zero.
This commit is contained in:
+5
-2
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user