mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-25 00:34:14 +03:00
Merge pull request #459 from jpharvey/getfont_leak
stop leaking filename parameter passed to getfont
This commit is contained in:
commit
2fc4a7441f
18
_imagingft.c
18
_imagingft.c
|
@ -113,12 +113,6 @@ getfont(PyObject* self_, PyObject* args, PyObject* kw)
|
||||||
"filename", "size", "index", "encoding", "font_bytes", NULL
|
"filename", "size", "index", "encoding", "font_bytes", NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "eti|iss#", kwlist,
|
|
||||||
Py_FileSystemDefaultEncoding, &filename,
|
|
||||||
&size, &index, &encoding, &font_bytes,
|
|
||||||
&font_bytes_size))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!library) {
|
if (!library) {
|
||||||
PyErr_SetString(
|
PyErr_SetString(
|
||||||
PyExc_IOError,
|
PyExc_IOError,
|
||||||
|
@ -126,10 +120,18 @@ getfont(PyObject* self_, PyObject* args, PyObject* kw)
|
||||||
);
|
);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
if (!PyArg_ParseTupleAndKeywords(args, kw, "eti|iss#", kwlist,
|
||||||
|
Py_FileSystemDefaultEncoding, &filename,
|
||||||
|
&size, &index, &encoding, &font_bytes,
|
||||||
|
&font_bytes_size))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
self = PyObject_New(FontObject, &Font_Type);
|
self = PyObject_New(FontObject, &Font_Type);
|
||||||
if (!self)
|
if (!self) {
|
||||||
|
if (filename)
|
||||||
|
PyMem_Free(filename);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (filename && font_bytes_size <= 0) {
|
if (filename && font_bytes_size <= 0) {
|
||||||
error = FT_New_Face(library, filename, index, &self->face);
|
error = FT_New_Face(library, filename, index, &self->face);
|
||||||
|
@ -146,6 +148,8 @@ getfont(PyObject* self_, PyObject* args, PyObject* kw)
|
||||||
);
|
);
|
||||||
error = FT_Select_Charmap(self->face, encoding_tag);
|
error = FT_Select_Charmap(self->face, encoding_tag);
|
||||||
}
|
}
|
||||||
|
if (filename)
|
||||||
|
PyMem_Free(filename);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
PyObject_Del(self);
|
PyObject_Del(self);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user