From 1b4d8636c1e6e67c5c1b1c748ef60965c6f361c8 Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Sat, 21 Mar 2026 03:39:57 +0000 Subject: [PATCH] Fix potential access violations with stale laser particle system IDs --- .../Source/GameLogic/Object/Update/LaserUpdate.cpp | 10 ++++++++++ .../Source/GameLogic/Object/Update/LaserUpdate.cpp | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/LaserUpdate.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/LaserUpdate.cpp index 6c323c786f5..8e53b6491fe 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/LaserUpdate.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/LaserUpdate.cpp @@ -291,6 +291,11 @@ void LaserUpdate::initLaser( const Object *parent, const Coord3D *startPos, cons { system->setPosition( &m_startPos ); } + else + { + // Particle system no longer exists; clear the stale ID to prevent future access violations. + m_particleSystemID = INVALID_PARTICLE_SYSTEM_ID; + } } if( m_targetParticleSystemID ) { @@ -299,6 +304,11 @@ void LaserUpdate::initLaser( const Object *parent, const Coord3D *startPos, cons { system->setPosition( &m_endPos ); } + else + { + // Particle system no longer exists; clear the stale ID to prevent future access violations. + m_targetParticleSystemID = INVALID_PARTICLE_SYSTEM_ID; + } } //Important! Set the laser position to the average of both points or else diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/LaserUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/LaserUpdate.cpp index 5214a726b5f..e8bd76f831d 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/LaserUpdate.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/LaserUpdate.cpp @@ -392,6 +392,11 @@ void LaserUpdate::initLaser( const Object *parent, const Object *target, const C { system->setPosition( &m_startPos ); } + else + { + // Particle system no longer exists; clear the stale ID to prevent future access violations. + m_particleSystemID = INVALID_PARTICLE_SYSTEM_ID; + } } //PLEASE NOTE You cannot check an ID for nullptr. This should be a check against INVALID_PARTICLE_SYSTEM_ID. Can't change it on the last day without a bug though. @@ -402,6 +407,11 @@ void LaserUpdate::initLaser( const Object *parent, const Object *target, const C { system->setPosition( &m_endPos ); } + else + { + // Particle system no longer exists; clear the stale ID to prevent future access violations. + m_targetParticleSystemID = INVALID_PARTICLE_SYSTEM_ID; + } } //Important! Set the laser position to the average of both points or else