1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 15:52:55 +01:00

Fix #15442: Use after free in object manager

This commit is contained in:
ζeh Matt
2021-09-21 01:34:58 -07:00
committed by GitHub
parent fddf009afc
commit c56810e6a5

View File

@@ -63,15 +63,18 @@ namespace Editor
static void object_list_load()
{
auto* context = GetContext();
// Unload objects first, the repository is re-populated which owns the objects.
auto& objectManager = context->GetObjectManager();
objectManager.UnloadAll();
// Scan objects if necessary
auto context = GetContext();
const auto& localisationService = context->GetLocalisationService();
auto& objectRepository = context->GetObjectRepository();
objectRepository.LoadOrConstruct(localisationService.GetCurrentLanguage());
// Reset loaded objects to just defaults
auto& objectManager = context->GetObjectManager();
objectManager.UnloadAll();
objectManager.LoadDefaultObjects();
}