[subset] Fix hhea subsetting and clean up some memory leaks.

This commit is contained in:
Garret Rieger 2018-02-14 16:37:35 -08:00
parent b56c9384bc
commit 0775bc0f7a
1 changed files with 14 additions and 11 deletions

View File

@ -76,26 +76,29 @@ struct hmtxvmtx
return false; return false;
} }
hb_blob_t *src_blob = OT::Sanitizer<H>().sanitize (plan->source->reference_table (T::tableTag)); hb_blob_t *src_blob = OT::Sanitizer<H>().sanitize (plan->source->reference_table (H::tableTag));
if (unlikely(!src_blob)) unsigned int src_length;
{ const char *src_raw = hb_blob_get_data (src_blob, &src_length);
free(dest); hb_blob_destroy (src_blob);
if (src_length != sizeof (H)) {
free (dest);
return false; return false;
} }
unsigned int src_length;
const char *src_raw = hb_blob_get_data(src_blob, &src_length);
memcpy(dest, src_raw, src_length); memcpy(dest, src_raw, src_length);
H *table = (H *) dest; H *table = (H *) dest;
table->numberOfLongMetrics.set(num_hmetrics); table->numberOfLongMetrics.set (num_hmetrics);
hb_blob_t *dest_blob = hb_blob_create ((const char *)dest, hb_blob_t *dest_blob = hb_blob_create ((const char *) dest,
dest_sz, dest_sz,
HB_MEMORY_MODE_READONLY, HB_MEMORY_MODE_READONLY,
/* userdata */ nullptr, dest,
free); free);
return hb_subset_plan_add_table(plan, H::tableTag, dest_blob); bool result = hb_subset_plan_add_table (plan, H::tableTag, dest_blob);
hb_blob_destroy (dest_blob);
return result;
} }
inline bool subset (hb_subset_plan_t *plan) const inline bool subset (hb_subset_plan_t *plan) const