From c7a4449e3660294ee769035a65eb82f3da1f7567 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 20 Feb 2022 19:31:19 +0100 Subject: [PATCH] Fixed a use-after-free in GameSelectorComponent. --- es-core/src/components/GameSelectorComponent.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/es-core/src/components/GameSelectorComponent.h b/es-core/src/components/GameSelectorComponent.h index c828fdf17..8a7f7a2c0 100644 --- a/es-core/src/components/GameSelectorComponent.h +++ b/es-core/src/components/GameSelectorComponent.h @@ -25,6 +25,13 @@ public: mSystem->getRootFolder()->setUpdateListCallback([&]() { mNeedsRefresh = true; }); } + ~GameSelectorComponent() + { + if (std::find(SystemData::sSystemVector.cbegin(), SystemData::sSystemVector.cend(), + mSystem) != SystemData::sSystemVector.cend()) + mSystem->getRootFolder()->setUpdateListCallback(nullptr); + } + enum class GameSelection { RANDOM, // Replace with AllowShortEnumsOnASingleLine: false (clang-format >=11.0). LAST_PLAYED,