From 388879e6d9f1e8cbb9f16bacf73ad77b9d5d7dd5 Mon Sep 17 00:00:00 2001 From: Mauller <26652186+Mauller@users.noreply.github.com> Date: Sun, 20 Apr 2025 18:45:20 +0100 Subject: [PATCH] [GEN][ZH] Fix drawable assignment in StealthUpdate::changeVisualDisguise() (#730) Co-authored-by: Helmut Buhler --- .../Source/GameLogic/Object/Update/StealthUpdate.cpp | 4 +++- .../Source/GameLogic/Object/Update/StealthUpdate.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/StealthUpdate.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/StealthUpdate.cpp index 8f94cb04af..96f8ca46ba 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/StealthUpdate.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/StealthUpdate.cpp @@ -755,7 +755,9 @@ void StealthUpdate::changeVisualDisguise() const ThingTemplate *tTemplate = self->getTemplate(); - TheThingFactory->newDrawable( tTemplate ); + // TheSuperHackers @fix helmutbuhler 13/04/2025 Fixes missing pointer assignment for the new drawable. + // This originally caused no runtime crash because the new drawable is allocated at the same address as the previously deleted drawable via the MemoryPoolBlob. + draw = TheThingFactory->newDrawable( tTemplate ); if( draw ) { TheGameLogic->bindObjectAndDrawable(self, draw); diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StealthUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StealthUpdate.cpp index 260f86224c..1aac39716d 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StealthUpdate.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StealthUpdate.cpp @@ -1055,7 +1055,9 @@ void StealthUpdate::changeVisualDisguise() const ThingTemplate *tTemplate = self->getTemplate(); - TheThingFactory->newDrawable( tTemplate ); + // TheSuperHackers @fix helmutbuhler 13/04/2025 Fixes missing pointer assignment for the new drawable. + // This originally caused no runtime crash because the new drawable is allocated at the same address as the previously deleted drawable via the MemoryPoolBlob. + draw = TheThingFactory->newDrawable( tTemplate ); if( draw ) { TheGameLogic->bindObjectAndDrawable(self, draw);