Skip to content
Closed
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
3 changes: 2 additions & 1 deletion Generals/Code/GameEngine/Include/Common/GameMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,8 @@ class MemoryPoolObject

void deleteInstance()
{
if (this)
void * volatile checkThisPtr = this; // mitigate undefined behavior because this function is called on nullptrs
if (checkThisPtr)
{
MemoryPool *pool = this->getObjectMemoryPool(); // save this, since the dtor will nuke our vtbl
this->~MemoryPoolObject(); // it's virtual, so the right one will be called.
Expand Down
3 changes: 2 additions & 1 deletion GeneralsMD/Code/GameEngine/Include/Common/GameMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,8 @@ class MemoryPoolObject

void deleteInstance()
{
if (this)
void * volatile checkThisPtr = this; // mitigate undefined behavior because this function is called on nullptrs
if (checkThisPtr)
{
MemoryPool *pool = this->getObjectMemoryPool(); // save this, since the dtor will nuke our vtbl
this->~MemoryPoolObject(); // it's virtual, so the right one will be called.
Expand Down