From 3276f2925dcf637bde47dbb306604c07284e2ce7 Mon Sep 17 00:00:00 2001 From: def Date: Mon, 21 Sep 2020 10:19:13 +0200 Subject: [PATCH] Reload skin menu when skin count changed fixes graphics bug when new skins are added, skins array is reallocated and we accessed freed memory Thanks to Jupeyy & Learath2 for also looking into this --- src/game/client/components/menus_settings.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index a9fad720d..d595d5b43 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -555,8 +555,9 @@ void CMenus::RenderSettingsTee(CUIRect MainView) MainView.HSplitTop(20.0f, 0, &MainView); MainView.HSplitTop(230.0f, &SkinList, &MainView); static sorted_array s_paSkinList; + static int s_SkinCount = 0; static float s_ScrollValue = 0.0f; - if(s_InitSkinlist) + if(s_InitSkinlist || m_pClient->m_pSkins->Num() != s_SkinCount) { s_paSkinList.clear(); for(int i = 0; i < m_pClient->m_pSkins->Num(); ++i) @@ -575,9 +576,10 @@ void CMenus::RenderSettingsTee(CUIRect MainView) if (g_Config.m_ClVanillaSkinsOnly && !s->m_IsVanilla) continue; - s_paSkinList.add(s); + s_paSkinList.add_unsorted(s); } s_InitSkinlist = false; + s_SkinCount = m_pClient->m_pSkins->Num(); } int OldSelected = -1;