[ot-layout] Fix nullptr dereference.

If the `calloc` for `gsub_accels` or `gpos_accels` fails, then the
unlikely branch afterwards can be taken, which frees up the
`hb_ot_layout_t`, but since those fields can now be `nullptr`, then
we don't want to dereference them.
This commit is contained in:
Bruce Mitchener 2018-01-31 22:24:51 +07:00 committed by Behdad Esfahbod
parent 0c66043a92
commit 148ca61075
1 changed files with 6 additions and 4 deletions

View File

@ -195,8 +195,10 @@ _hb_ot_layout_create (hb_face_t *face)
void
_hb_ot_layout_destroy (hb_ot_layout_t *layout)
{
if (layout->gsub_accels)
for (unsigned int i = 0; i < layout->gsub_lookup_count; i++)
layout->gsub_accels[i].fini ();
if (layout->gpos_accels)
for (unsigned int i = 0; i < layout->gpos_lookup_count; i++)
layout->gpos_accels[i].fini ();