Check for alloc failures on the gsub/gpos_langsys maps in subset plan creation.
This commit is contained in:
parent
29708e959a
commit
3c8273ab68
|
@ -373,16 +373,20 @@ hb_subset_plan_create (hb_face_t *face,
|
|||
plan->gsub_lookups = hb_map_create ();
|
||||
plan->gpos_lookups = hb_map_create ();
|
||||
|
||||
plan->gsub_langsys = hb_object_create<script_langsys_map> ();
|
||||
plan->gsub_langsys->init_shallow ();
|
||||
if (plan->check_success (plan->gsub_langsys = hb_object_create<script_langsys_map> ()))
|
||||
plan->gsub_langsys->init_shallow ();
|
||||
if (plan->check_success (plan->gpos_langsys = hb_object_create<script_langsys_map> ()))
|
||||
plan->gpos_langsys->init_shallow ();
|
||||
|
||||
plan->gpos_langsys = hb_object_create<script_langsys_map> ();
|
||||
plan->gpos_langsys->init_shallow ();
|
||||
plan->gsub_features = hb_map_create ();
|
||||
plan->gpos_features = hb_map_create ();
|
||||
plan->layout_variation_indices = hb_set_create ();
|
||||
plan->layout_variation_idx_map = hb_map_create ();
|
||||
|
||||
if (plan->in_error ()) {
|
||||
return plan;
|
||||
}
|
||||
|
||||
_populate_gids_to_retain (plan,
|
||||
input->unicodes,
|
||||
input->glyphs,
|
||||
|
@ -429,19 +433,25 @@ hb_subset_plan_destroy (hb_subset_plan_t *plan)
|
|||
hb_set_destroy (plan->layout_variation_indices);
|
||||
hb_map_destroy (plan->layout_variation_idx_map);
|
||||
|
||||
for (auto _ : plan->gsub_langsys->iter ())
|
||||
hb_set_destroy (_.second);
|
||||
if (plan->gsub_langsys)
|
||||
{
|
||||
for (auto _ : plan->gsub_langsys->iter ())
|
||||
hb_set_destroy (_.second);
|
||||
|
||||
hb_object_destroy (plan->gsub_langsys);
|
||||
plan->gsub_langsys->fini_shallow ();
|
||||
free (plan->gsub_langsys);
|
||||
hb_object_destroy (plan->gsub_langsys);
|
||||
plan->gsub_langsys->fini_shallow ();
|
||||
free (plan->gsub_langsys);
|
||||
}
|
||||
|
||||
for (auto _ : plan->gpos_langsys->iter ())
|
||||
hb_set_destroy (_.second);
|
||||
if (plan->gpos_langsys)
|
||||
{
|
||||
for (auto _ : plan->gpos_langsys->iter ())
|
||||
hb_set_destroy (_.second);
|
||||
|
||||
hb_object_destroy (plan->gpos_langsys);
|
||||
plan->gpos_langsys->fini_shallow ();
|
||||
free (plan->gpos_langsys);
|
||||
hb_object_destroy (plan->gpos_langsys);
|
||||
plan->gpos_langsys->fini_shallow ();
|
||||
free (plan->gpos_langsys);
|
||||
}
|
||||
|
||||
free (plan);
|
||||
}
|
||||
|
|
|
@ -302,8 +302,10 @@ hb_subset (hb_face_t *source, hb_subset_input_t *input)
|
|||
if (unlikely (!input || !source)) return hb_face_get_empty ();
|
||||
|
||||
hb_subset_plan_t *plan = hb_subset_plan_create (source, input);
|
||||
if (unlikely (plan->in_error ()))
|
||||
if (unlikely (plan->in_error ())) {
|
||||
hb_subset_plan_destroy (plan);
|
||||
return hb_face_get_empty ();
|
||||
}
|
||||
|
||||
hb_set_t tags_set;
|
||||
bool success = true;
|
||||
|
|
Loading…
Reference in New Issue