[gvar] Protect against offset underflow

This commit is contained in:
Behdad Esfahbod 2022-05-06 13:02:26 -06:00
parent 9a6dabd61a
commit dd71d2c1c3
1 changed files with 3 additions and 1 deletions

View File

@ -479,7 +479,9 @@ struct gvar
const hb_bytes_t get_glyph_var_data_bytes (hb_blob_t *blob, hb_codepoint_t glyph) const
{
unsigned start_offset = get_offset (glyph);
unsigned length = get_offset (glyph+1) - start_offset;
unsigned end_offset = get_offset (glyph+1);
if (unlikely (end_offset < start_offset)) return hb_bytes_t ();
unsigned length = end_offset - start_offset;
hb_bytes_t var_data = blob->as_bytes ().sub_array (((unsigned) dataZ) + start_offset, length);
return likely (var_data.length >= GlyphVariationData::min_size) ? var_data : hb_bytes_t ();
}