From ffb61968f02d3aa5a945078a5349a2c7647d4070 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Mon, 30 May 2016 03:56:28 -0700 Subject: [PATCH] Initialize ptr and guard call to free --- _imagingft.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/_imagingft.c b/_imagingft.c index 218d8b141..d2ff66e25 100644 --- a/_imagingft.c +++ b/_imagingft.c @@ -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); }