From b186274362725b7501211c2a782c1a0badd57107 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 29 Oct 2018 23:21:14 -0700 Subject: [PATCH] [set/map] Fix uninitialized memory I keep forgetting that primitive types are NOT initialized during construction. :| --- src/hb-map.hh | 4 ++-- src/hb-object.hh | 1 + src/hb-set.hh | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/hb-map.hh b/src/hb-map.hh index e5ca3f515..c54c9d7b6 100644 --- a/src/hb-map.hh +++ b/src/hb-map.hh @@ -45,8 +45,8 @@ inline uint32_t Hash (const T &v) struct hb_map_t { HB_NO_COPY_ASSIGN (hb_map_t); - inline hb_map_t (void) { init_shallow (); } - inline ~hb_map_t (void) { fini_shallow (); } + inline hb_map_t (void) { init (); } + inline ~hb_map_t (void) { fini (); } struct item_t { diff --git a/src/hb-object.hh b/src/hb-object.hh index d347b5ffa..106f59206 100644 --- a/src/hb-object.hh +++ b/src/hb-object.hh @@ -272,6 +272,7 @@ static inline void hb_object_fini (Type *obj) { user_data->fini (); free (user_data); + user_data = nullptr; } } template diff --git a/src/hb-set.hh b/src/hb-set.hh index 97ff291eb..0755498ba 100644 --- a/src/hb-set.hh +++ b/src/hb-set.hh @@ -40,8 +40,8 @@ struct hb_set_t { HB_NO_COPY_ASSIGN (hb_set_t); - inline hb_set_t (void) { init_shallow (); } - inline ~hb_set_t (void) { fini_shallow (); } + inline hb_set_t (void) { init (); } + inline ~hb_set_t (void) { fini (); } struct page_map_t {