From 7d4e81de0b120fc2ea17eb4d1c2ef46a45c975f8 Mon Sep 17 00:00:00 2001 From: Vladislav Nikolaevich Date: Sat, 6 Nov 2021 14:28:52 +0300 Subject: [PATCH] Fix small memory leak for engineRequestModel --- Client/game_sa/CModelInfoSA.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Client/game_sa/CModelInfoSA.cpp b/Client/game_sa/CModelInfoSA.cpp index 39991070fb..97a46692cb 100644 --- a/Client/game_sa/CModelInfoSA.cpp +++ b/Client/game_sa/CModelInfoSA.cpp @@ -1509,6 +1509,22 @@ void CModelInfoSA::MakeVehicleAutomobile(ushort usBaseID) void CModelInfoSA::DeallocateModel(void) { Remove(); + + switch (GetModelType()) + { + case eModelInfoType::VEHICLE: + delete reinterpret_cast(ppModelInfo[m_dwModelID]); + break; + case eModelInfoType::PED: + delete reinterpret_cast(ppModelInfo[m_dwModelID]); + break; + case eModelInfoType::ATOMIC: + delete reinterpret_cast(ppModelInfo[m_dwModelID]); + break; + default: + break; + } + ppModelInfo[m_dwModelID] = nullptr; pGame->GetStreaming()->GetStreamingInfoFromModelId(m_dwModelID)->Reset(); }