Skip to content

Commit

Permalink
SporeModManager: fix memory leaks in SporeMod::InstallSporeMod() and …
Browse files Browse the repository at this point in the history
…SporeModManager::UpdateMod()
  • Loading branch information
Rosalie241 committed Jul 24, 2022
1 parent 31b0a1e commit 7be6cc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions SporeModManager/SporeModManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 8 additions & 0 deletions SporeModManager/SporeModManagerHelpers/SporeMod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 7be6cc4

Please sign in to comment.