From fd9903fc4e31aeb570cd86d96765b5851759c44e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 6 Apr 2025 16:04:17 -0600 Subject: [PATCH] [hb-subset] Try to fix leak --- util/face-options.hh | 10 +++++++--- util/hb-subset.cc | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/util/face-options.hh b/util/face-options.hh index ed1e75825..7248e0ea5 100644 --- a/util/face-options.hh +++ b/util/face-options.hh @@ -33,12 +33,16 @@ struct face_options_t { ~face_options_t () { - g_free (face_loader); g_free (font_file); + g_free (face_loader); + hb_face_destroy (face); } void set_face (hb_face_t *face_) - { face = face_; } + { + hb_face_destroy (face); + face = hb_face_reference (face_); + } void add_options (option_parser_t *parser); @@ -116,7 +120,7 @@ face_options_t::post_parse (GError **error) } } - face = cache.face; + set_face (cache.face); } static G_GNUC_NORETURN gboolean diff --git a/util/hb-subset.cc b/util/hb-subset.cc index 15669577a..431edda34 100644 --- a/util/hb-subset.cc +++ b/util/hb-subset.cc @@ -71,7 +71,7 @@ struct subset_main_t : option_parser_t, face_options_t, output_options_t main2.option_parser_t::parse (&argc, &args); g_free (args); - set_face (hb_face_reference (main2.face)); + set_face (main2.face); } void parse (int argc, char **argv)