From 7be6cc438569b1aee00e9143d6ffc1e71dd8a68e Mon Sep 17 00:00:00 2001 From: Rosalie Wanders Date: Sun, 24 Jul 2022 20:04:09 +0200 Subject: [PATCH] SporeModManager: fix memory leaks in SporeMod::InstallSporeMod() and SporeModManager::UpdateMod() --- SporeModManager/SporeModManager.cpp | 2 ++ SporeModManager/SporeModManagerHelpers/SporeMod.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/SporeModManager/SporeModManager.cpp b/SporeModManager/SporeModManager.cpp index 9262743..1e50d12 100644 --- a/SporeModManager/SporeModManager.cpp +++ b/SporeModManager/SporeModManager.cpp @@ -108,6 +108,8 @@ bool SporeModManager::UpdateMod(std::filesystem::path path) // make sure we have the modapi dll that the mod requires if (!FileVersion::CheckIfCoreLibMatchesVersion(sporeModInfo.MinimumModAPILibVersion, sporeModInfo.Name)) { + free(modInfoFileBuffer); + Zip::CloseFile(zipFile); return false; } diff --git a/SporeModManager/SporeModManagerHelpers/SporeMod.cpp b/SporeModManager/SporeModManagerHelpers/SporeMod.cpp index e38abbb..92332f8 100644 --- a/SporeModManager/SporeModManagerHelpers/SporeMod.cpp +++ b/SporeModManager/SporeModManagerHelpers/SporeMod.cpp @@ -135,12 +135,16 @@ bool SporeMod::InstallSporeMod(std::filesystem::path path) // already installed if (IsModAlreadyInstalled(sporeModInfo.UniqueName)) { + free(modInfoFileBuffer); + Zip::CloseFile(zipFile); return false; } // make sure we have the modapi dll that the mod requires if (!FileVersion::CheckIfCoreLibMatchesVersion(sporeModInfo.MinimumModAPILibVersion, sporeModInfo.Name)) { + free(modInfoFileBuffer); + Zip::CloseFile(zipFile); return false; } @@ -165,6 +169,8 @@ bool SporeMod::InstallSporeMod(std::filesystem::path path) UI::AskUserInput(inputText, userAnswer, false); if (!userAnswer) { + free(modInfoFileBuffer); + Zip::CloseFile(zipFile); return false; } } @@ -230,6 +236,8 @@ bool SporeMod::InstallSporeMod(std::filesystem::path path) // file collision detection if (CheckIfOtherModContainsFiles(installedSporeMod.InstalledFiles)) { + free(modInfoFileBuffer); + Zip::CloseFile(zipFile); return false; }