From eff92173d4c55ba09396429dfdccfbdbd5689008 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Mon, 2 Dec 2013 10:15:59 -0500 Subject: [PATCH 1/2] Don't free a font that hasn't been created --- src/ft2font.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ft2font.cpp b/src/ft2font.cpp index 0fb3b8b65825..673bdb2969c4 100644 --- a/src/ft2font.cpp +++ b/src/ft2font.cpp @@ -846,6 +846,7 @@ PYCXX_NOARGS_METHOD_DECL(FT2Font, get_path) FT2Font::FT2Font(Py::PythonClassInstance *self, Py::Tuple &args, Py::Dict &kwds) : Py::PythonClass(self, args, kwds), + face(NULL), image() { FT_Open_Args open_args; @@ -975,7 +976,9 @@ FT2Font::~FT2Font() { _VERBOSE("FT2Font::~FT2Font"); - FT_Done_Face(face); + if (face) { + FT_Done_Face(face); + } for (size_t i = 0; i < glyphs.size(); i++) { From ec2212e664619d8f1013fe20bc5757ab2ca41743 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Mon, 2 Dec 2013 15:28:54 -0500 Subject: [PATCH 2/2] Don't clear glyphs if the face was never created. --- src/ft2font.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ft2font.cpp b/src/ft2font.cpp index 673bdb2969c4..1d94adf26d40 100644 --- a/src/ft2font.cpp +++ b/src/ft2font.cpp @@ -978,11 +978,11 @@ FT2Font::~FT2Font() if (face) { FT_Done_Face(face); - } - for (size_t i = 0; i < glyphs.size(); i++) - { - FT_Done_Glyph(glyphs[i]); + for (size_t i = 0; i < glyphs.size(); i++) + { + FT_Done_Glyph(glyphs[i]); + } } }