[subset-cff] Pre-allocate values array for subroutines as well

This commit is contained in:
Behdad Esfahbod 2022-11-21 18:18:48 -07:00
parent c6279224db
commit dc3bb5e0ed
2 changed files with 6 additions and 0 deletions

View File

@ -328,6 +328,8 @@ struct byte_str_ref_t
void set_error () { str.backwards_length = str.length + 1; }
bool in_error () const { return str.backwards_length > str.length; }
unsigned total_size () const { return str.length; }
protected:
hb_ubytes_t str;
};

View File

@ -442,8 +442,12 @@ struct subr_subset_param_t
if (unlikely (calling && !parsed_str->is_parsed () && (parsed_str->values.length > 0)))
env.set_error ();
else
{
if (!parsed_str->is_parsed ())
parsed_str->alloc (env.str_ref.total_size () / 2);
current_parsed_str = parsed_str;
}
}
parsed_cs_str_t *current_parsed_str;