Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2168,6 +2168,15 @@ void Object::onCollide( Object *other, const Coord3D *loc, const Coord3D *normal
#endif
break;
}

// If this object or the other object has been destroyed by a previous
// collide module handler, stop processing further modules to avoid
// accessing freed/invalid memory (null pointer dereference).
if( isDestroyed() )
break;
if( other != nullptr && other->isDestroyed() )
break;

#ifdef DEBUG_CRC
//DEBUG_LOG(("Object::onCollide() - calling collide module"));
#endif
Expand Down
9 changes: 9 additions & 0 deletions GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2445,6 +2445,15 @@ void Object::onCollide( Object *other, const Coord3D *loc, const Coord3D *normal
#endif
break;
}

// If this object or the other object has been destroyed by a previous
// collide module handler, stop processing further modules to avoid
// accessing freed/invalid memory (null pointer dereference).
if( isDestroyed() )
break;
if( other != nullptr && other->isDestroyed() )
break;

#ifdef DEBUG_CRC
//DEBUG_LOG(("Object::onCollide() - calling collide module"));
#endif
Expand Down
Loading