Skip to content

fix(rendering): Prevent crash in Render2DClass::Set_Texture and fix REF_PTR_SET self-assignment - #546

Open
seer-by-sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/client-2ry-render2d-texture-crash
Open

fix(rendering): Prevent crash in Render2DClass::Set_Texture and fix REF_PTR_SET self-assignment#546
seer-by-sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/client-2ry-render2d-texture-crash

Conversation

@seer-by-sentry

@seer-by-sentry seer-by-sentry Bot commented Aug 2, 2026

Copy link
Copy Markdown

This PR addresses issue CLIENT-2RY, a recurring fatal crash in Render2DClass::Set_Texture.

Root Cause:
W3DDisplay::drawImage was passing a null pointer, obtained from image->getRawTextureData(), directly to Render2DClass::Set_Texture without a null check. This occurred when an image (e.g., for a text entry gadget) had no raw texture data, leading to an EXCEPTION_ACCESS_VIOLATION_WRITE.

Additionally, the REF_PTR_SET macro in refcount.h was identified as having a potential self-assignment bug (though less directly related to this specific crash, it was part of a previously unmerged fix).

Changes Implemented:

  1. Null Check in W3DDisplay::drawImage: Added a null check for the tex pointer immediately after image->getRawTextureData() is called in both Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp and GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp. If tex is null, the function now returns early, preventing the crash.
  2. REF_PTR_SET Self-Assignment Fix: Modified the REF_PTR_SET macro in Core/Libraries/Source/WWVegas/WWLib/refcount.h to include a if ((dst) != (src)) guard. This ensures that Add_Ref() and Release_Ref() are only called when assigning a different object, preventing potential issues with self-assignment and unnecessary reference count operations.

These fixes correspond to previously identified but unmerged PRs (#436 for the null check and #293 for the REF_PTR_SET macro).

Fixes CLIENT-2RY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants