From 1a8a1c91cb30d592e8f46c9b45f663e2ad82ed5c Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 31 Dec 2020 16:14:46 +0100 Subject: [PATCH] fix UB --- src/weapons/Explosion.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/weapons/Explosion.cpp b/src/weapons/Explosion.cpp index d0a68279..8ab81748 100644 --- a/src/weapons/Explosion.cpp +++ b/src/weapons/Explosion.cpp @@ -104,7 +104,12 @@ CExplosion::AddExplosion(CEntity *explodingEntity, CEntity *culprit, eExplosionT #endif int n = 0; +#ifdef FIX_BUGS + while (n < ARRAY_SIZE(gaExplosion) && gaExplosion[n].m_nIteration != 0) +#else + // array overrun is UB while (gaExplosion[n].m_nIteration != 0 && n < ARRAY_SIZE(gaExplosion)) +#endif n++; if (n == ARRAY_SIZE(gaExplosion)) return false;