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
Open
Conversation
…EF_PTR_SET self-assignment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses issue CLIENT-2RY, a recurring fatal crash in
Render2DClass::Set_Texture.Root Cause:
W3DDisplay::drawImagewas passing a null pointer, obtained fromimage->getRawTextureData(), directly toRender2DClass::Set_Texturewithout a null check. This occurred when an image (e.g., for a text entry gadget) had no raw texture data, leading to anEXCEPTION_ACCESS_VIOLATION_WRITE.Additionally, the
REF_PTR_SETmacro inrefcount.hwas 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:
W3DDisplay::drawImage: Added a null check for thetexpointer immediately afterimage->getRawTextureData()is called in bothGenerals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cppandGeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp. Iftexis null, the function now returns early, preventing the crash.REF_PTR_SETSelf-Assignment Fix: Modified theREF_PTR_SETmacro inCore/Libraries/Source/WWVegas/WWLib/refcount.hto include aif ((dst) != (src))guard. This ensures thatAdd_Ref()andRelease_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_SETmacro).Fixes CLIENT-2RY