Skip to content

bugfix(replay): Stop dereferencing a null slot when a replay has no local player - #3240

Draft
bobtista wants to merge 3 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/bugfix/replay-null-local-player-slot
Draft

bugfix(replay): Stop dereferencing a null slot when a replay has no local player#3240
bobtista wants to merge 3 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/bugfix/replay-null-local-player-slot

Conversation

@bobtista

Copy link
Copy Markdown

A replay whose local player index is -1 dereferenced a missing slot in two places. RecorderClass::playbackFile read the local slot to tell a network game from a local one, and GameLogic::startNewGame read it again to mark the local player. readReplayHeader accepts -1 and GameInfo::getSlot returns nullptr for a negative slot, so such a replay crashed before it could play.

Now the replay CRC queue is primed from the recorded game mode, which answers the network question directly and keeps the CRC alignment a network replay needs, and the local slot lookup during game start treats a missing local slot as no slot being local.

Verified with a replay byte-edited to carry -1: it crashes before the change and plays to completion after it. Twelve unmodified replays produce identical CRC results before and after.

Todo:

  • Both games build (z_generals and g_generals)
  • Replicate to Generals
  • Replay with no local player crashes before the change
  • Replay with no local player plays to completion after the change
  • Unmodified replays report identical CRC results before and after

@bobtista bobtista self-assigned this Aug 30, 2026
@bobtista bobtista added the Bug Something is not working right, typically is user facing label Aug 30, 2026
@Caball009

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something is not working right, typically is user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replay playback dereferences a null slot when the local player index is -1

2 participants