Make lazy loader deal with OOM

This commit is contained in:
Behdad Esfahbod 2018-08-03 19:54:33 -07:00
parent 30ff8ac865
commit 7df7963b46
1 changed files with 5 additions and 1 deletions

View File

@ -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<Stored **>(&this->instance), nullptr, p)))
{
thiz ()->destroy (p);