[subset] destruct cff accelerator if present.

This commit is contained in:
Garret Rieger 2022-11-25 18:38:13 +00:00
parent 71c23c1c07
commit 75a99f28ab
2 changed files with 10 additions and 3 deletions

View File

@ -60,6 +60,10 @@ struct hb_subset_accelerator_t
if (!value) return;
hb_subset_accelerator_t* accel = (hb_subset_accelerator_t*) value;
if (accel->cff_accelerator && accel->destroy_cff_accelerator)
accel->destroy_cff_accelerator ((void*) accel->cff_accelerator);
accel->~hb_subset_accelerator_t ();
hb_free (accel);
}
@ -67,7 +71,7 @@ struct hb_subset_accelerator_t
hb_subset_accelerator_t(const hb_map_t& unicode_to_gid_,
const hb_set_t& unicodes_)
: unicode_to_gid(unicode_to_gid_), unicodes(unicodes_),
has_seac(false), cff_accelerator(nullptr) {}
has_seac(false), cff_accelerator(nullptr), destroy_cff_accelerator(nullptr) {}
// Generic
const hb_map_t unicode_to_gid;
@ -76,6 +80,7 @@ struct hb_subset_accelerator_t
// CFF
bool has_seac;
CFF::cff_subset_accelerator_t* cff_accelerator;
hb_destroy_func_t destroy_cff_accelerator;
// TODO(garretrieger): cumulative glyf checksum map
// TODO(garretrieger): sanitized table cache.

View File

@ -404,7 +404,7 @@ struct parsed_cs_str_vec_t : hb_vector_t<parsed_cs_str_t>
struct cff_subset_accelerator_t
{
static cff_subset_accelerator_t* create(
static cff_subset_accelerator_t* create (
hb_face_t* original_face,
const parsed_cs_str_vec_t& parsed_charstrings,
const parsed_cs_str_vec_t& parsed_global_subrs,
@ -418,7 +418,7 @@ struct cff_subset_accelerator_t
return accel;
}
static void destroy(void* value) {
static void destroy (void* value) {
if (!value) return;
cff_subset_accelerator_t* accel = (cff_subset_accelerator_t*) value;
@ -1025,6 +1025,8 @@ struct subr_subsetter_t
parsed_charstrings,
parsed_global_subrs,
parsed_local_subrs);
plan->inprogress_accelerator->destroy_cff_accelerator =
cff_subset_accelerator_t::destroy;
}