From 9938d04ca797ab2ad28c86ce0d446aa65782ca67 Mon Sep 17 00:00:00 2001 From: shfil Date: Thu, 31 Dec 2020 16:33:34 +0100 Subject: Fix UB in ProjectileInfo.cpp --- src/weapons/ProjectileInfo.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/weapons/ProjectileInfo.cpp') diff --git a/src/weapons/ProjectileInfo.cpp b/src/weapons/ProjectileInfo.cpp index b56e3a29..da00b87a 100644 --- a/src/weapons/ProjectileInfo.cpp +++ b/src/weapons/ProjectileInfo.cpp @@ -128,8 +128,12 @@ CProjectileInfo::AddProjectile(CEntity *entity, eWeaponType weapon, CVector pos, } int i = 0; +#ifdef FIX_BUGS + while (i < ARRAY_SIZE(gaProjectileInfo) && gaProjectileInfo[i].m_bInUse) i++; +#else + // array overrun is UB while (gaProjectileInfo[i].m_bInUse && i < ARRAY_SIZE(gaProjectileInfo)) i++; - +#endif if (i == ARRAY_SIZE(gaProjectileInfo)) return false; -- cgit v1.2.3