From e62ef00f652f364c914bed0735242a6623f4bbb9 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 23 Jan 2025 12:12:07 +0100 Subject: [PATCH] WIP - Fixed leak due to indirectly recursing ImFontAtlasPackInit(). --- imgui_draw.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 2b753c414..5c2616059 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -3860,8 +3860,6 @@ void ImFontAtlasBuildCompactTexture(ImFontAtlas* atlas) // Start packing over current empty texture void ImFontAtlasBuildInit(ImFontAtlas* atlas) { - ImFontAtlasBuilder* builder = atlas->Builder; - // Select Backend // - Note that we do not reassign to atlas->FontLoader, since it is likely to point to static data which // may mess with some hot-reloading schemes. If you need to assign to this (for dynamic selection) AND are @@ -3876,14 +3874,20 @@ void ImFontAtlasBuildInit(ImFontAtlas* atlas) #else IM_ASSERT(0); // Invalid Build function #endif + return; // ImFontAtlasBuildSetupFontBackendIO() automatically call ImFontAtlasBuildInit() } + // Create initial texture size if (atlas->TexData == NULL) ImFontAtlasBuildAddTexture(atlas, ImUpperPowerOfTwo(atlas->TexMinWidth), ImUpperPowerOfTwo(atlas->TexMinHeight)); + ImFontAtlasBuilder* builder = atlas->Builder; // Do not move above const bool builder_is_new = (builder == NULL); if (builder_is_new) + { + IM_ASSERT(atlas->Builder == NULL); builder = atlas->Builder = IM_NEW(ImFontAtlasBuilder)(); + } ImFontAtlasBuildUpdateRendererHasTexturesFromContext(atlas);