From e3db3e38116c098a002e5aa5c725e17a5aa64ee1 Mon Sep 17 00:00:00 2001 From: Causeless Date: Wed, 22 Nov 2023 22:52:04 +0000 Subject: [PATCH] More complete module id error checking (stops OOB access from lua script) --- Managers/PresetMan.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Managers/PresetMan.cpp b/Managers/PresetMan.cpp index 86ca9d14c..6bdc2aecd 100644 --- a/Managers/PresetMan.cpp +++ b/Managers/PresetMan.cpp @@ -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]; } @@ -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 ////////////////////////////////////////////////////////////////////////////////////////// @@ -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;