Skip to content

Commit

Permalink
Fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
cgohlke committed Jun 25, 2019
1 parent ea570a8 commit 47f7eba
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/_imagingft.c
Original file line number Diff line number Diff line change
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 47f7eba

Please sign in to comment.