From 872f594df087d0670d1d0ac9b09020aabeb4b307 Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Thu, 26 Mar 2026 18:00:47 +0000 Subject: [PATCH] bugfix(collision): Prevent null dereference in PartitionManager --- .../GameEngine/Source/GameLogic/Object/PartitionManager.cpp | 3 +++ .../GameEngine/Source/GameLogic/Object/PartitionManager.cpp | 3 +++ 2 files changed, 6 insertions(+) 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.