From f1f6bc0a6f28a6611a247f37b8a83e6f782d7227 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 2 May 2018 12:56:21 -0400 Subject: [PATCH] [set] Fix init/fini of set on the stack to call object init/fini Part of https://github.com/harfbuzz/harfbuzz/issues/1017 --- src/hb-set-private.hh | 14 ++++++++++++-- src/hb-set.cc | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh index 4288b15b3..149b89e2a 100644 --- a/src/hb-set-private.hh +++ b/src/hb-set-private.hh @@ -193,18 +193,28 @@ struct hb_set_t hb_vector_t page_map; hb_vector_t pages; - inline void init (void) + inline void init_shallow (void) { in_error = false; population = 0; page_map.init (); pages.init (); } - inline void fini (void) + inline void init (void) + { + hb_object_init (this); + init_shallow (); + } + inline void fini_shallow (void) { page_map.fini (); pages.fini (); } + inline void fini (void) + { + hb_object_fini (this); + fini_shallow (); + } inline bool resize (unsigned int count) { diff --git a/src/hb-set.cc b/src/hb-set.cc index d5163c784..2bad18898 100644 --- a/src/hb-set.cc +++ b/src/hb-set.cc @@ -45,7 +45,7 @@ hb_set_create (void) if (!(set = hb_object_create ())) return hb_set_get_empty (); - set->init (); + set->init_shallow (); return set; } @@ -96,7 +96,7 @@ hb_set_destroy (hb_set_t *set) { if (!hb_object_destroy (set)) return; - set->fini (); + set->fini_shallow (); free (set); }