From 66ed417d45dc274815a4aaf7add2e101fb3f2a7c Mon Sep 17 00:00:00 2001 From: whitequark Date: Mon, 10 Oct 2016 21:16:22 +0000 Subject: [PATCH] Fix a handle leak in TtfFontList::PlotString. --- src/ttf.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ttf.cpp b/src/ttf.cpp index 32cd1f6..3d3e1f4 100644 --- a/src/ttf.cpp +++ b/src/ttf.cpp @@ -88,7 +88,9 @@ void TtfFontList::PlotString(const std::string &font, const std::string &str, [&](const TtfFont &tf) { return tf.FontFileBaseName() == font; }); if(!str.empty() && tf != &l.elem[l.n]) { - tf->LoadFromFile(fontLibrary, /*nameOnly=*/false); + if(tf->fontFace == NULL) { + tf->LoadFromFile(fontLibrary, /*nameOnly=*/false); + } tf->PlotString(str, sbl, origin, u, v); } else { // No text or no font; so draw a big X for an error marker. @@ -135,6 +137,7 @@ bool TtfFont::LoadFromFile(FT_Library fontLibrary, bool nameOnly) { dbp("freetype: loading unicode CMap for file '%s' failed: %s", fontFile.c_str(), ft_error_string(fterr)); FT_Done_Face(fontFace); + fontFace = NULL; return false; }