[ENOMEM] fix memory leak if allocation fails during pop_pack().

This commit is contained in:
Garret Rieger 2020-07-29 16:37:39 -07:00 committed by Ebrahim Byagowi
parent 42237adffc
commit 15644ee60e
2 changed files with 5 additions and 1 deletions

View File

@ -256,8 +256,12 @@ struct hb_serialize_context_t
packed.push (obj); packed.push (obj);
if (unlikely (packed.in_error ())) if (unlikely (packed.in_error ())) {
// obj wasn't successfully added to packed, so clean it up otherwise it's
// links will be leaked.
obj->fini ();
return 0; return 0;
}
objidx = packed.length - 1; objidx = packed.length - 1;