Skip to content

fix(logic): Fix potential null pointer deferences in GameLogicDispatch#2354

Merged
xezon merged 1 commit into
TheSuperHackers:mainfrom
stephanmeesters:fix-gamelogicdispatch-null
Feb 28, 2026
Merged

fix(logic): Fix potential null pointer deferences in GameLogicDispatch#2354
xezon merged 1 commit into
TheSuperHackers:mainfrom
stephanmeesters:fix-gamelogicdispatch-null

Conversation

@stephanmeesters

Copy link
Copy Markdown

Scanned through GameLogicDispatch and found some possible null pointer deference issues.

@greptile-apps

greptile-apps Bot commented Feb 26, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes potential null pointer dereferences in GameLogicDispatch by adding defensive null checks and making the AIGroup::isEmpty() method const-qualified.

Key changes:

  • Made isEmpty() const in both declaration and implementation, enabling it to be called on const AIGroup* pointers
  • Added empty group check in getSingleObjectFromSelection() to prevent accessing an empty selection and triggering an incorrect assertion
  • Added null check for targetObject in the combat drop message handler before dereferencing it, preventing crashes when the target object doesn't exist

All changes are mirrored correctly between Generals and GeneralsMD (Zero Hour) directories and follow the existing code patterns for null safety in the file.

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • All changes are defensive null checks that prevent potential crashes without altering intended program logic. The const qualifier addition is a best practice that enables calling isEmpty() on const pointers. Changes are consistent with existing null-check patterns in the codebase and are correctly mirrored across both game versions.
  • No files require special attention

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp Fixed two null pointer dereference issues: added empty check in getSingleObjectFromSelection() and null check for targetObject before dereferencing in combat drop handler
GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp Fixed two null pointer dereference issues (identical to Generals version)

Last reviewed commit: 0be8c37

@xezon xezon changed the title fix: Fix possible null pointer deference in GameLogicDispatch fix(logic): Fix potential null pointer deferences in GameLogicDispatch Feb 27, 2026
@xezon xezon added Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Fix Is fixing something, but is not user facing Stability Concerns stability of the runtime labels Feb 27, 2026
@xezon xezon merged commit e99984e into TheSuperHackers:main Feb 28, 2026
25 checks passed
Okladnoj pushed a commit to Okladnoj/GeneralsGameCode that referenced this pull request Mar 1, 2026
@stephanmeesters stephanmeesters deleted the fix-gamelogicdispatch-null branch April 13, 2026 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Fix Is fixing something, but is not user facing Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker Stability Concerns stability of the runtime ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants