mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-27 02:16:19 +03:00
Fix memory leak
This commit is contained in:
parent
ea570a8c5b
commit
47f7eba279
|
@ -1006,6 +1006,9 @@ font_render(FontObject* self, PyObject* args)
|
||||||
|
|
||||||
num_coords = PyObject_Length(axes);
|
num_coords = PyObject_Length(axes);
|
||||||
coords = malloc(2 * sizeof(coords));
|
coords = malloc(2 * sizeof(coords));
|
||||||
|
if (coords == NULL) {
|
||||||
|
return PyErr_NoMemory();
|
||||||
|
}
|
||||||
for (i = 0; i < num_coords; i++) {
|
for (i = 0; i < num_coords; i++) {
|
||||||
item = PyList_GET_ITEM(axes, i);
|
item = PyList_GET_ITEM(axes, i);
|
||||||
if (PyFloat_Check(item))
|
if (PyFloat_Check(item))
|
||||||
|
@ -1015,6 +1018,7 @@ font_render(FontObject* self, PyObject* args)
|
||||||
else if (PyNumber_Check(item))
|
else if (PyNumber_Check(item))
|
||||||
coord = PyFloat_AsDouble(item);
|
coord = PyFloat_AsDouble(item);
|
||||||
else {
|
else {
|
||||||
|
free(coords);
|
||||||
PyErr_SetString(PyExc_TypeError, "list must contain numbers");
|
PyErr_SetString(PyExc_TypeError, "list must contain numbers");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1022,6 +1026,7 @@ font_render(FontObject* self, PyObject* args)
|
||||||
}
|
}
|
||||||
|
|
||||||
error = FT_Set_Var_Design_Coordinates(self->face, num_coords, coords);
|
error = FT_Set_Var_Design_Coordinates(self->face, num_coords, coords);
|
||||||
|
free(coords);
|
||||||
if (error)
|
if (error)
|
||||||
return geterror(error);
|
return geterror(error);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user