diff --git a/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp b/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp index e209263398..2841377d9e 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp @@ -95,6 +95,10 @@ void PolygonTrigger::reallocate(void) { DEBUG_ASSERTCRASH(m_numPoints <= m_sizePoints, ("Invalid m_numPoints.")); if (m_numPoints == m_sizePoints) { + if (m_sizePoints > INT_MAX / 2) { + DEBUG_CRASH(("Too many points to allocate.")); + return; + } // Reallocate. m_sizePoints += m_sizePoints; ICoord3D *newPts = NEW ICoord3D[m_sizePoints]; diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp index 5e1dc0fb65..a0878a76b4 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp @@ -97,6 +97,10 @@ void PolygonTrigger::reallocate(void) { DEBUG_ASSERTCRASH(m_numPoints <= m_sizePoints, ("Invalid m_numPoints.")); if (m_numPoints == m_sizePoints) { + if (m_sizePoints > INT_MAX / 2) { + DEBUG_CRASH(("Too many points to allocate.")); + return; + } // Reallocate. m_sizePoints += m_sizePoints; ICoord3D *newPts = NEW ICoord3D[m_sizePoints];