-
Notifications
You must be signed in to change notification settings - Fork 151
fix(shadow): Fix crash by initializing debris shadow name to an empty string #2221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Greptile Overview
|
| Filename | Overview |
|---|---|
| Generals/Code/GameEngine/Include/GameClient/Shadow.h | Added default constructor to ShadowTypeInfo that initializes all members including m_ShadowName[0] = '\0' to prevent uninitialized memory access |
| GeneralsMD/Code/GameEngine/Include/GameClient/Shadow.h | Added default constructor to ShadowTypeInfo that initializes all members including m_ShadowName[0] = '\0' to prevent uninitialized memory access |
Sequence Diagram
sequenceDiagram
participant Client as Game Client
participant Debris as W3DDebrisDraw
participant Shadow as ShadowTypeInfo
participant Manager as W3DShadowManager
participant Projected as W3DProjectedShadow
Note over Client,Projected: Before Fix (Crash Scenario)
Client->>Debris: Create debris with shadow
Debris->>Shadow: Instantiate ShadowTypeInfo
Note over Shadow: m_ShadowName contains<br/>garbage data (uninitialized)
Debris->>Shadow: Set m_type = t
Debris->>Manager: addShadow(renderObject, &shadowInfo)
Manager->>Projected: Process shadow creation
Projected->>Projected: Check strlen(m_ShadowName) <= 1
Note over Projected: FAIL: Garbage data makes<br/>strlen unpredictable
Projected->>Projected: Check m_ShadowName[0] != '\0'
Note over Projected: FAIL: Garbage data present
Projected->>Projected: strcpy(texture_name, m_ShadowName)
Note over Projected: CRASH: Passes garbage<br/>to texture loader
Note over Client,Projected: After Fix (Proper Initialization)
Client->>Debris: Create debris with shadow
Debris->>Shadow: Instantiate ShadowTypeInfo
Note over Shadow: Constructor initializes:<br/>m_ShadowName[0] = '\0'<br/>All members initialized
Debris->>Shadow: Set m_type = t
Debris->>Manager: addShadow(renderObject, &shadowInfo)
Manager->>Projected: Process shadow creation
Projected->>Projected: Check strlen(m_ShadowName) <= 1
Note over Projected: SUCCESS: strlen = 0
Projected->>Projected: Use default texture
Note over Projected: No crash, proper behavior
|
Perhaps there should be a default constructor for |
Good thinking. Updated! |
|
Does this tend to only get hit under mod use? |
Zero Hour does not have |
xezon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Needs to be rebased and merged after #2225
This change fixes a crash caused by spawning a
CreateDebrisobject with an assignedShadowby initializing the shadow name to an empty string.When the shadow name is uninitialized, checks for
'\0'andstrlen <= 1fail and garbage data is instead passed to various locations that do not expect it nor know how to deal with it.