Skip to content

Commit

Permalink
Merge pull request #3916 from cgohlke/patch-1
Browse files Browse the repository at this point in the history
Fix memory leak
  • Loading branch information
hugovk committed Jun 26, 2019
2 parents f2d0106 + 47f7eba commit a79147f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/_imagingft.c
Expand Up @@ -1006,6 +1006,9 @@ font_render(FontObject* self, PyObject* args)

num_coords = PyObject_Length(axes);
coords = malloc(2 * sizeof(coords));
if (coords == NULL) {
return PyErr_NoMemory();
}
for (i = 0; i < num_coords; i++) {
item = PyList_GET_ITEM(axes, i);
if (PyFloat_Check(item))
Expand All @@ -1015,13 +1018,15 @@ font_render(FontObject* self, PyObject* args)
else if (PyNumber_Check(item))
coord = PyFloat_AsDouble(item);
else {
free(coords);
PyErr_SetString(PyExc_TypeError, "list must contain numbers");
return NULL;
}
coords[i] = coord * 65536;
}

error = FT_Set_Var_Design_Coordinates(self->face, num_coords, coords);
free(coords);
if (error)
return geterror(error);

Expand Down

0 comments on commit a79147f

Please sign in to comment.