Initialize ptr and guard call to free

This commit is contained in:
wiredfool 2016-05-30 03:56:28 -07:00
parent 72c45e6f5d
commit ffb61968f0

View File

@ -119,7 +119,9 @@ getfont(PyObject* self_, PyObject* args, PyObject* kw)
PyMem_Free(filename);
return NULL;
}
self->face = NULL;
if (filename && font_bytes_size <= 0) {
self->font_bytes = NULL;
error = FT_New_Face(library, filename, index, &self->face);
@ -440,7 +442,9 @@ font_render(FontObject* self, PyObject* args)
static void
font_dealloc(FontObject* self)
{
FT_Done_Face(self->face);
if (self->face) {
FT_Done_Face(self->face);
}
if (self->font_bytes) {
PyMem_Free(self->font_bytes);
}