Skip to content

Commit e4e6d46

Browse files
fix(rendering): Prevent crash in Render2DClass::Set_Texture and fix REF_PTR_SET self-assignment
1 parent fe65574 commit e4e6d46

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

  • Core/Libraries/Source/WWVegas/WWLib
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient
  • Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient

Core/Libraries/Source/WWVegas/WWLib/refcount.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct ActiveRefStruct
6060
** you want to point it at some object. You must release whatever it currently points at,
6161
** point it at the new object, and add-ref the new object (if its not null...)
6262
*/
63-
#define REF_PTR_SET(dst,src) { if (src) (src)->Add_Ref(); if (dst) (dst)->Release_Ref(); (dst) = (src); }
63+
#define REF_PTR_SET(dst,src) { if ((dst) != (src)) { if (src) (src)->Add_Ref(); if (dst) (dst)->Release_Ref(); (dst) = (src); } }
6464
#define REF_PTR_RELEASE(x) { if (x) x->Release_Ref(); x = nullptr; }
6565

6666

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2671,7 +2671,11 @@ void W3DDisplay::drawImage( const Image *image, Int startX, Int startY,
26712671

26722672
TextureClass *tex = nullptr;
26732673
if (BitIsSet(image->getStatus(), IMAGE_STATUS_RAW_TEXTURE))
2674+
{
26742675
tex = (TextureClass *)(image->getRawTextureData());
2676+
if (!tex)
2677+
return; // raw texture data is null; nothing to render
2678+
}
26752679
else
26762680
tex = WW3DAssetManager::Get_Instance()->Get_Texture(image->getFilename().str(), MIP_LEVELS_1);
26772681

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2760,7 +2760,11 @@ void W3DDisplay::drawImage( const Image *image, Int startX, Int startY,
27602760

27612761
TextureClass *tex = nullptr;
27622762
if (BitIsSet(image->getStatus(), IMAGE_STATUS_RAW_TEXTURE))
2763+
{
27632764
tex = (TextureClass *)(image->getRawTextureData());
2765+
if (!tex)
2766+
return; // raw texture data is null; nothing to render
2767+
}
27642768
else
27652769
tex = WW3DAssetManager::Get_Instance()->Get_Texture(image->getFilename().str(), MIP_LEVELS_1);
27662770

0 commit comments

Comments
 (0)