forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 245
bugfix(object): Avoid crash with dangling contain module in Object::onDestroy() when Troop Crawler is destroyed while en route to Reinforcement Pad #3165
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
Open
Caball009
wants to merge
4
commits into
TheSuperHackers:main
Choose a base branch
from
Caball009:Caball009/fix_use_after_free_troop_crawler
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+41
−163
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3c9383b
Revert "bugfix(contain): Restore retail compatibility after changes t…
Caball009 c5c0b8e
Revert "bugfix(object): Avoid crash with dangling contain module in O…
Caball009 43a5e69
Retained relevant changes.
Caball009 831ff73
Added early container size check to avoid crash.
Caball009 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -177,6 +177,15 @@ OpenContain::~OpenContain() | |
| ("OpenContain %s: m_xferContainIDList is not empty but should be", | ||
| getObject()->getTemplate()->getName().str() ) ); | ||
|
|
||
| #if RETAIL_COMPATIBLE_CRC | ||
| // TheSuperHackers @bugfix Caball009 18/08/2026 Due to a potential use-after-free bug that cannot be fixed | ||
| // with retail compatibility, it's desirable to be able to check if the contain list is empty after its destruction. | ||
| // Empty the list explicitly to reset the list size. | ||
| while (!m_containList.empty()) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't we just call |
||
| { | ||
| m_containList.pop_front(); | ||
| } | ||
| #endif | ||
| } | ||
|
|
||
| //------------------------------------------------------------------------------------------------- | ||
|
|
@@ -434,6 +443,15 @@ void OpenContain::removeFromContain( Object *rider, Bool exposeStealthUnits ) | |
|
|
||
| } | ||
|
|
||
| #if RETAIL_COMPATIBLE_CRC | ||
| // TheSuperHackers @bugfix Caball009 18/08/2026 Due to a potential use-after-free bug that cannot be fixed | ||
| // with retail compatibility, the 'contained by' pointer of this object may point to an already destroyed object. | ||
| // Check the list size before executing the find operation below, otherwise the game crashes if the list | ||
| // was already destructed. | ||
| if (m_containList.empty()) | ||
| return; | ||
| #endif | ||
|
|
||
| ContainedItemsList::iterator it = std::find(m_containList.begin(), m_containList.end(), rider); | ||
| if (it != m_containList.end()) | ||
| { | ||
|
|
||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.