From bc447bc0a4b398f371867ceaa65f26e5c094484f Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 24 Oct 2017 16:08:05 +0200 Subject: [PATCH] ImFontAtlas: Fixed memory leak if stbtt_InitFont() returned false. (#1391) --- imgui_draw.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index c3a5f3d5..8137f476 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1475,7 +1475,10 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas) const int font_offset = stbtt_GetFontOffsetForIndex((unsigned char*)cfg.FontData, cfg.FontNo); IM_ASSERT(font_offset >= 0); if (!stbtt_InitFont(&tmp.FontInfo, (unsigned char*)cfg.FontData, font_offset)) + { + ImGui::MemFree(tmp_array); return false; + } } // Allocate packing character data and flag packed characters buffer as non-packed (x0=y0=x1=y1=0)