Skip to content

[Crash] Unchecked this.loadout[ItemType.*] array access in client initialization #71

@coderabbitai

Description

@coderabbitai

Summary

Game server crashes when this.loadout array is undefined during client setup.

Affected Code

server-game/src/client.js:139-143, 160-164, 489, 523-527

this.player.changeCharacter(
  this.classIdx,
  this.loadout[ItemType.Primary],    // CRASH if this.loadout undefined
  this.loadout[ItemType.Secondary],
  this.colorIdx,
  this.loadout[ItemType.Hat],
  this.loadout[ItemType.Stamp],
);

Vulnerability

If client initialization fails before loadout is set.

Impact

  • Game server crash on player join
  • Denial of service

Recommended Fix

Initialize loadout with defaults:

if (!this.loadout) {
  this.loadout = [];
}

Or use optional chaining:

this.loadout?.[ItemType.Primary]

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions