[GX] Handle setting var coords to NULL

This commit is contained in:
Behdad Esfahbod 2016-09-10 01:58:27 -07:00
parent 59055b5494
commit c22176d4ba
1 changed files with 5 additions and 3 deletions

View File

@ -1560,8 +1560,8 @@ hb_font_set_var_coords_normalized (hb_font_t *font,
while (coords_length && !coords[coords_length - 1])
coords_length--;
int *copy = (int *) calloc (coords_length, sizeof (coords[0]));
if (unlikely (!copy))
int *copy = coords_length ? (int *) calloc (coords_length, sizeof (coords[0])) : NULL;
if (unlikely (coords_length && !copy))
return;
if (font->x_coords)
@ -1569,7 +1569,9 @@ hb_font_set_var_coords_normalized (hb_font_t *font,
if (font->y_coords && font->y_coords != font->x_coords)
free (font->y_coords);
memcpy (copy, coords, coords_length * sizeof (coords[0]));
if (coords_length)
memcpy (copy, coords, coords_length * sizeof (coords[0]));
font->x_coords = font->y_coords = copy;
font->num_coords = coords_length;
}