From 6bc3e7b043634bbc09cae0cf8ea308f98bd65c3f Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 13 Feb 2018 21:56:54 +0100 Subject: [PATCH] ImFontAtlas: if stbtt_PackBegin() because of failing allocation we return a little more nicely. (keeps Coverity static analyzer happy!) --- imgui_draw.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 10051c4f..e7abffb5 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1688,7 +1688,8 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas) // Start packing const int max_tex_height = 1024*32; stbtt_pack_context spc = {}; - stbtt_PackBegin(&spc, NULL, atlas->TexWidth, max_tex_height, 0, atlas->TexGlyphPadding, NULL); + if (!stbtt_PackBegin(&spc, NULL, atlas->TexWidth, max_tex_height, 0, atlas->TexGlyphPadding, NULL)) + return false; stbtt_PackSetOversampling(&spc, 1, 1); // Pack our extra data rectangles first, so it will be on the upper-left corner of our texture (UV will have small values).