Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
More complete module id error checking (stops OOB access from lua scr…
Browse files Browse the repository at this point in the history
…ipt)
  • Loading branch information
Causeless committed Nov 22, 2023
1 parent 001f917 commit e3db3e3
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Managers/PresetMan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ bool PresetMan::LoadAllDataModules() {

const DataModule * PresetMan::GetDataModule(int whichModule)
{
RTEAssert(whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!");
RTEAssert(whichModule >= 0 && whichModule < m_pDataModules.size(), "Tried to access an out of bounds data module number!");
return m_pDataModules[whichModule];
}

Expand All @@ -220,12 +220,10 @@ const DataModule * PresetMan::GetDataModule(int whichModule)

const std::string PresetMan::GetDataModuleName(int whichModule)
{
RTEAssert(whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!");
RTEAssert(whichModule >= 0 && whichModule < m_pDataModules.size(), "Tried to access an out of bounds data module number!");
return m_pDataModules[whichModule]->GetFileName();
}



//////////////////////////////////////////////////////////////////////////////////////////
// Method: GetModuleID
//////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -374,7 +372,7 @@ bool PresetMan::AddEntityPreset(Entity *pEntToAdd, int whichModule, bool overwri

const Entity * PresetMan::GetEntityPreset(std::string type, std::string preset, int whichModule)
{
RTEAssert(whichModule < (int)m_pDataModules.size(), "Tried to access an out of bounds data module number!");
RTEAssert(whichModule >= 0 && whichModule < m_pDataModules.size(), "Tried to access an out of bounds data module number!");

const Entity *pRetEntity = 0;

Expand Down

0 comments on commit e3db3e3

Please sign in to comment.