From 47f7eba279296ed2977cfd4108ed62ac38c4ce7f Mon Sep 17 00:00:00 2001 From: Christoph Gohlke Date: Tue, 25 Jun 2019 13:33:49 -0700 Subject: [PATCH] Fix memory leak --- src/_imagingft.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/_imagingft.c b/src/_imagingft.c index f6bd787ef5c..964ed6ab1d4 100644 --- a/src/_imagingft.c +++ b/src/_imagingft.c @@ -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)) @@ -1015,6 +1018,7 @@ 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; } @@ -1022,6 +1026,7 @@ font_render(FontObject* self, PyObject* args) } error = FT_Set_Var_Design_Coordinates(self->face, num_coords, coords); + free(coords); if (error) return geterror(error);