diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/WeaponSet.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/WeaponSet.cpp index 3d140d352e6..2597d553bbb 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/WeaponSet.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/WeaponSet.cpp @@ -1065,6 +1065,11 @@ Bool WeaponSet::setWeaponLock( WeaponSlotType weaponSlot, WeaponLockType lockTyp return false; } + if (static_cast(weaponSlot) >= ARRAY_SIZE(m_weapons)) + { + return false; + } + // Verify the asked for weapon exists , choose it, and then lock it as chosen until unlocked // the old code was just plain wrong. (look at it in perforce and you'll see...) if (m_weapons[weaponSlot] != nullptr) diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/WeaponSet.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/WeaponSet.cpp index aeafb6dd7ae..1fa309ee8a8 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/WeaponSet.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/WeaponSet.cpp @@ -1109,6 +1109,11 @@ Bool WeaponSet::setWeaponLock( WeaponSlotType weaponSlot, WeaponLockType lockTyp return false; } + if (static_cast(weaponSlot) >= ARRAY_SIZE(m_weapons)) + { + return false; + } + // Verify the asked for weapon exists , choose it, and then lock it as chosen until unlocked // the old code was just plain wrong. (look at it in perforce and you'll see...) if (m_weapons[weaponSlot] != nullptr)