From eecccc919ce15f60ae7ef9da5cfb311b4aa05c63 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 11 Nov 2018 15:48:47 -0500 Subject: [PATCH] Don't store to null object Ouch :). --- src/hb-machinery.hh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh index c85c69d75..160e99a58 100644 --- a/src/hb-machinery.hh +++ b/src/hb-machinery.hh @@ -782,10 +782,6 @@ struct hb_lazy_loader_t : hb_data_wrapper_t inline Stored * do_create (void) const { - Stored *p = this->template call_create (); - if (unlikely (!p)) - p = const_cast (Funcs::get_null ()); - return p; } static inline void do_destroy (Stored *p) { @@ -803,7 +799,10 @@ struct hb_lazy_loader_t : hb_data_wrapper_t Stored *p = this->instance.get (); if (unlikely (!p)) { - p = do_create (); + p = this->template call_create (); + if (unlikely (!p)) + return const_cast (Funcs::get_null ()); + if (unlikely (!this->instance.cmpexch (nullptr, p))) { do_destroy (p);