From dc3bb5e0ed4f44e3a11474656ecf2cd8b7d86a68 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 21 Nov 2022 18:18:48 -0700 Subject: [PATCH] [subset-cff] Pre-allocate values array for subroutines as well --- src/hb-cff-interp-common.hh | 2 ++ src/hb-subset-cff-common.hh | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/hb-cff-interp-common.hh b/src/hb-cff-interp-common.hh index 10f62cbc1..e90207a5b 100644 --- a/src/hb-cff-interp-common.hh +++ b/src/hb-cff-interp-common.hh @@ -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; }; diff --git a/src/hb-subset-cff-common.hh b/src/hb-subset-cff-common.hh index 14d0b4341..152898524 100644 --- a/src/hb-subset-cff-common.hh +++ b/src/hb-subset-cff-common.hh @@ -442,7 +442,11 @@ 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;