From 84e9e106c131b8ad9ffa98ba5d141af445cc219c Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sat, 5 Jul 2025 13:22:45 +0100 Subject: [PATCH] Codefix: SpriteFontCache was never deleted. (#14414) --- src/fontcache.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/fontcache.cpp b/src/fontcache.cpp index fb1d757c62..f0e7f5ce73 100644 --- a/src/fontcache.cpp +++ b/src/fontcache.cpp @@ -43,7 +43,7 @@ FontCache::FontCache(FontSize fs) : parent(FontCache::Get(fs)), fs(fs), height(_ /** Clean everything up. */ FontCache::~FontCache() { - assert(this->fs == this->parent->fs); + assert(this->parent == nullptr || this->fs == this->parent->fs); FontCache::caches[this->fs] = this->parent; Layouter::ResetFontCache(this->fs); } @@ -241,8 +241,7 @@ void InitFontCache(bool monospace) void UninitFontCache() { for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) { - FontCache *fc = FontCache::Get(fs); - if (fc->HasParent()) delete fc; + while (FontCache::Get(fs) != nullptr) delete FontCache::Get(fs); } #ifdef WITH_FREETYPE