From 9ed5f04a7092c76744076ba65673b250aee22dcd Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 29 Mar 2021 18:14:30 -0600 Subject: [PATCH] [subset] Simplify recent out-of-memory fixes By checking return status of map->set(). --- src/hb-ot-layout-common.hh | 8 ++++---- src/hb-ot-layout-gsubgpos.hh | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 384127c52..8b8eaabe4 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -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; } } diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index 1e9f2f465..f82097680 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -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 ();