From 9dbea6071a41eb8595e888146c74ea7efb790455 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 25 Jun 2023 14:28:02 -0600 Subject: [PATCH] [subset/cff1] Fix resource leak in error case --- src/hb-subset-cff1.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/hb-subset-cff1.cc b/src/hb-subset-cff1.cc index 8b9f2308b..79a64770b 100644 --- a/src/hb-subset-cff1.cc +++ b/src/hb-subset-cff1.cc @@ -492,16 +492,6 @@ struct cff1_subset_plan return; } - hb_vector_t *glyph_to_sid_map = acc.cff_accelerator ? - acc.cff_accelerator->glyph_to_sid_map.get_acquire () : - nullptr; - bool created_map = false; - if (!glyph_to_sid_map && acc.cff_accelerator) - { - created_map = true; - glyph_to_sid_map = acc.create_glyph_to_sid_map (); - } - code_pair_t glyph_to_sid_cache {0, HB_CODEPOINT_INVALID}; unsigned int glyph; @@ -514,6 +504,16 @@ struct cff1_subset_plan return; } + hb_vector_t *glyph_to_sid_map = acc.cff_accelerator ? + acc.cff_accelerator->glyph_to_sid_map.get_acquire () : + nullptr; + bool created_map = false; + if (!glyph_to_sid_map && acc.cff_accelerator) + { + created_map = true; + glyph_to_sid_map = acc.create_glyph_to_sid_map (); + } + auto it = hb_iter (plan->new_to_old_gid_list); if (it->first == 0) it++; auto _ = *it;