diff --git a/src/hb-machinery-private.hh b/src/hb-machinery-private.hh index 9edd2be56..1eeae4b2e 100644 --- a/src/hb-machinery-private.hh +++ b/src/hb-machinery-private.hh @@ -626,7 +626,14 @@ struct hb_lazy_loader_t : hb_data_wrapper_t { inline void init0 (void) {} /* Init, when memory is already set to 0. No-op for us. */ inline void init (void) { instance.set_relaxed (nullptr); } - inline void fini (void) { destroy (instance.get ()); } + inline void fini (void) + { + retry: + Stored *p = instance.get (); + if (unlikely (p && !this->instance.cmpexch (p, nullptr))) + goto retry; + destroy (p); + } inline Stored * create (void) const {