fix(update): Fix value initialization of ProjectileStreamUpdate::m_projectileIDs#2248
Merged
xezon merged 4 commits intoTheSuperHackers:mainfrom Feb 3, 2026
Conversation
Greptile Overview
|
| Filename | Overview |
|---|---|
| Generals/Code/GameEngine/Source/GameLogic/Object/Update/ProjectileStreamUpdate.cpp | Fixed variable shadowing bug by properly initializing member m_projectileIDs array using std::fill, and reordered member initialization to match declaration order |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProjectileStreamUpdate.cpp | Fixed variable shadowing bug by properly initializing member m_projectileIDs array using std::fill, and reordered member initialization to match declaration order |
Sequence Diagram
sequenceDiagram
participant Client as Game System
participant Constructor as ProjectileStreamUpdate()
participant Member as m_projectileIDs[20]
Note over Client,Member: Before Fix - Variable Shadowing Bug
Client->>Constructor: new ProjectileStreamUpdate()
Constructor->>Constructor: ObjectID m_projectileIDs[20] (local)
Constructor->>Constructor: for loop initializes local array
Note over Constructor: Local array destroyed!
Constructor->>Member: Member array left uninitialized
Constructor-->>Client: Return (undefined behavior)
Note over Client,Member: After Fix - Correct Initialization
Client->>Constructor: new ProjectileStreamUpdate()
Constructor->>Member: std::fill(m_projectileIDs, ..., INVALID_ID)
Constructor->>Member: m_nextFreeIndex = 0
Constructor->>Member: m_firstValidIndex = 0
Constructor->>Member: m_owningObject = INVALID_ID
Constructor-->>Client: Return (properly initialized)
xezon
approved these changes
Feb 3, 2026
githubawn
pushed a commit
to githubawn/GeneralsGameCode
that referenced
this pull request
Feb 5, 2026
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 properly initializes
ProjectileStreamUpdate::m_projectileIDsinstead of a local array with the same name. This change is not user-facing because the memory allocators would still zero-initialize memory on allocation. I've also reordered the assignments to match the order of declaration.This class is used for the GLA Toxin Tractor and USA Ambulance on the first time they fire, and on loading a save game with these units if they have fired before.
TODO: