diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp index c954025bec..110117db95 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp @@ -1996,6 +1996,9 @@ Bool PartitionData::collidesWith(const PartitionData *that, CollideLocAndNormal const Object *thisObj = this->getObject(); const Object *thatObj = that->getObject(); + if( thisObj == nullptr || thatObj == nullptr ) + return FALSE; // One or both objects have been destroyed/unregistered; avoid null dereference. + if( thisObj->isKindOf( KINDOF_NO_COLLIDE ) || thatObj->isKindOf( KINDOF_NO_COLLIDE ) ) return FALSE; // A collision extent of zero size is still a point and can collide, but we don't always want to. diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp index b5e7985605..55afa413ce 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp @@ -2000,6 +2000,9 @@ Bool PartitionData::collidesWith(const PartitionData *that, CollideLocAndNormal const Object *thisObj = this->getObject(); const Object *thatObj = that->getObject(); + if( thisObj == nullptr || thatObj == nullptr ) + return FALSE; // One or both objects have been destroyed/unregistered; avoid null dereference. + if( thisObj->isKindOf( KINDOF_NO_COLLIDE ) || thatObj->isKindOf( KINDOF_NO_COLLIDE ) ) return FALSE; // A collision extent of zero size is still a point and can collide, but we don't always want to.