khaledhosny / ots

Sanitizer for OpenType
BSD 3-Clause "New" or "Revised" License
263 stars 63 forks source link

Avoid unhanded std::out_of_range exception in bad CFF2 font #239

Closed josh-hadley closed 2 years ago

josh-hadley commented 2 years ago

As discussed at https://github.com/khaledhosny/ots/pull/238#issuecomment-1002750392. Note that the root cause is that there is no PrivateDICT at all (not even an empty one), which is required for CFF2, and that condition was not being checked. So I added a check for that and fail early. In case we still somehow get to ValidateCFFCharStrings and attempt to access vsindex_per_font, I also added a check there to avoid an out-of-range exception. Also updated test suite with the font in question.