From 790ec36fb0564eba9d483e8f3bde690a41c93dc1 Mon Sep 17 00:00:00 2001 From: roiqd03 <91754567+roiqd03@users.noreply.github.com> Date: Wed, 8 May 2024 17:53:17 +0200 Subject: [PATCH] Font: Memory leak If HAVE_FREETYPE macro is not defined, the memory allocated in buffer is not freed --- Components/Overlay/src/OgreFont.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Components/Overlay/src/OgreFont.cpp b/Components/Overlay/src/OgreFont.cpp index 2eb7d422705..edcda4cb43a 100644 --- a/Components/Overlay/src/OgreFont.cpp +++ b/Components/Overlay/src/OgreFont.cpp @@ -528,6 +528,18 @@ namespace Ogre // Advance a column if(width) l += (width + char_spacer); + +#ifndef HAVE_FREETYPE + if (buffer != NULL) + { + int ix0, iy0, ix1, iy1; + stbtt__bitmap gbm; + stbtt_GetGlyphBitmapBoxSubpixel(&font, stbtt_FindGlyphIndex(&font, cp), scale, scale, 0.0f, 0.0f, &ix0, &iy0, &ix1, &iy1); + gbm.w = (ix1 - ix0); + gbm.h = (iy1 - iy0); + STBTT_free(buffer, gbm.w * gbm.h); + } +#endif } } #ifdef HAVE_FREETYPE