[subset] Simplify recent out-of-memory fixes

By checking return status of map->set().
This commit is contained in:
Behdad Esfahbod 2021-03-29 18:14:30 -06:00
parent a8f9f85a91
commit 9ed5f04a70
2 changed files with 10 additions and 10 deletions

View File

@ -701,10 +701,10 @@ struct Script
if (!c->script_langsys_map->has (script_index))
{
hb_set_t* empty_set = hb_set_create ();
c->script_langsys_map->set (script_index, empty_set);
if (!c->script_langsys_map->has (script_index)) {
hb_set_destroy (empty_set);
return;
if (unlikely (!c->script_langsys_map->set (script_index, empty_set)))
{
hb_set_destroy (empty_set);
return;
}
}

View File

@ -108,12 +108,12 @@ struct hb_closure_context_t :
if (!done_lookups_glyph_set->get (lookup_index))
{
hb_set_t* empty_set = hb_set_create ();
done_lookups_glyph_set->set (lookup_index, empty_set);
if (!done_lookups_glyph_set->get (lookup_index)) {
hb_set_destroy (empty_set);
return true;
}
hb_set_t* empty_set = hb_set_create ();
if (unlikely (!done_lookups_glyph_set->set (lookup_index, empty_set)))
{
hb_set_destroy (empty_set);
return true;
}
}
done_lookups_glyph_set->get (lookup_index)->clear ();