From ba3bc73676a96bfd301761548fff8f299cb7e87d Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Thu, 3 Nov 2022 20:23:27 +0000 Subject: [PATCH] VarAction2: Fix memory leak of inlinable adjust groups --- src/newgrf.cpp | 1 + src/newgrf_internal.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 708fc547de..d445c104ae 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -5825,6 +5825,7 @@ static void NewSpriteGroup(ByteReader *buf) ProcessDeterministicSpriteGroupRanges(ranges, group->ranges, group->default_group); OptimiseVarAction2DeterministicSpriteGroup(va2_opt_state, feature, varsize, group, current_adjusts); + current_adjusts.clear(); break; } diff --git a/src/newgrf_internal.h b/src/newgrf_internal.h index effc059a70..d9322bc9e7 100644 --- a/src/newgrf_internal.h +++ b/src/newgrf_internal.h @@ -129,6 +129,9 @@ public: this->group_temp_store_variable_tracking_storage.EmptyArena(); this->procedure_annotations.clear(); this->procedure_annotations_storage.EmptyArena(); + for (auto iter : this->inlinable_adjust_groups) { + iter.second->~vector(); + } this->inlinable_adjust_groups.clear(); this->inlinable_adjust_groups_storage.EmptyArena(); this->dead_store_elimination_candidates.clear();