From 7df7963b46223f47e89a5a38c597c874aaa93141 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 3 Aug 2018 19:54:33 -0700 Subject: [PATCH] Make lazy loader deal with OOM --- src/hb-machinery-private.hh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/hb-machinery-private.hh b/src/hb-machinery-private.hh index 0d2dbc3cd..119625c45 100644 --- a/src/hb-machinery-private.hh +++ b/src/hb-machinery-private.hh @@ -623,7 +623,11 @@ struct hb_lazy_loader_t if (unlikely (!p)) { hb_face_t *face = *(((hb_face_t **) this) - WheresFace); - p = thiz ()->create (face); + if (likely (!p)) + p = thiz ()->create (face); + if (unlikely (!p)) + p = thiz ()->create (nullptr); /* Produce nil object. */ + assert (p); if (unlikely (!hb_atomic_ptr_cmpexch (const_cast(&this->instance), nullptr, p))) { thiz ()->destroy (p);