Do not pass obviously invalid data to sfntly (invalid data tends to cause sfntly to segfault)

This commit is contained in:
Kovid Goyal 2012-10-30 16:29:29 +05:30
parent f8d9dead20
commit c3c64c452a

View File

@ -20,6 +20,9 @@ def load_sfntly():
return sfntly
def subset(font_data, individual_chars, ranges):
if font_data[:4] not in {b'\x00\x01\x00\x00', b'OTTO', b'true', b'typ1'}:
raise ValueError('Not a supported font file. sfnt_version not recognized: %r'%
font_data[:4])
individual = tuple(sorted(map(ord, individual_chars)))
cranges = []
for s, e in ranges: