summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2018-11-11 15:48:47 -0500
committerBehdad Esfahbod <behdad@behdad.org>2018-11-11 15:48:47 -0500
commiteecccc919ce15f60ae7ef9da5cfb311b4aa05c63 (patch)
tree9914915843d423dd53a88e491ffd3c207e20cb20
parent903856ab505cbc6b756d7b904650df72e90f67a7 (diff)
Don't store to null object
Ouch :).
-rw-r--r--src/hb-machinery.hh9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh
index c85c69d7..160e99a5 100644
--- a/src/hb-machinery.hh
+++ b/src/hb-machinery.hh
@@ -782,10 +782,6 @@ struct hb_lazy_loader_t : hb_data_wrapper_t<Data, WheresData>
inline Stored * do_create (void) const
{
- Stored *p = this->template call_create<Stored, Funcs> ();
- if (unlikely (!p))
- p = const_cast<Stored *> (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<Data, WheresData>
Stored *p = this->instance.get ();
if (unlikely (!p))
{
- p = do_create ();
+ p = this->template call_create<Stored, Funcs> ();
+ if (unlikely (!p))
+ return const_cast<Stored *> (Funcs::get_null ());
+
if (unlikely (!this->instance.cmpexch (nullptr, p)))
{
do_destroy (p);