Skip to content

Commit 98e59d5

Browse files
chief1983claude
andcommitted
Fix standalone web UI crash when polling player data before ship selection
playerGet() indexed Ship_info with ship_class without bounds checking. Before ship selection, ship_class is -1, which as an unsigned index causes an out-of-bounds access. Add the same bounds check that the Windows standalone GUI already has. Fixes #7366 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 18fd870 commit 98e59d5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

code/network/stand_gui-unix.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,11 @@ json_t* playerGet(ResourceContext * /*context*/) {
457457
json_object_set(obj, "host", (MULTI_HOST(p)) ? json_true() : json_false());
458458
json_object_set(obj, "observer", (MULTI_OBSERVER(p)) ? json_true() : json_false());
459459
json_object_set(obj, "callsign", json_string(p.m_player->callsign));
460-
json_object_set(obj, "ship", json_string(Ship_info[p.p_info.ship_class].name));
460+
if (p.p_info.ship_class >= 0 && p.p_info.ship_class < static_cast<int>(Ship_info.size())) {
461+
json_object_set(obj, "ship", json_string(Ship_info[p.p_info.ship_class].name));
462+
} else {
463+
json_object_set(obj, "ship", json_string(""));
464+
}
461465

462466
json_array_append(playerList, obj);
463467
}

0 commit comments

Comments
 (0)