Fix standalone web UI crash when polling player data before ship selection#7367
Open
chief1983 wants to merge 1 commit intoscp-fs2open:masterfrom
Open
Fix standalone web UI crash when polling player data before ship selection#7367chief1983 wants to merge 1 commit intoscp-fs2open:masterfrom
chief1983 wants to merge 1 commit intoscp-fs2open:masterfrom
Conversation
Member
|
Reckon this is another one that would be great to have @notimaginative's take on. |
notimaginative
requested changes
Apr 10, 2026
code/network/stand_gui-unix.cpp
Outdated
| json_object_set(obj, "observer", (MULTI_OBSERVER(p)) ? json_true() : json_false()); | ||
| json_object_set(obj, "callsign", json_string(p.m_player->callsign)); | ||
| json_object_set(obj, "ship", json_string(Ship_info[p.p_info.ship_class].name)); | ||
| if (p.p_info.ship_class >= 0 && p.p_info.ship_class < static_cast<int>(Ship_info.size())) { |
Contributor
There was a problem hiding this comment.
I believe using ship_info_size() is the preferred way to do the upper bounds check. Otherwise this looks good to me.
Member
Author
There was a problem hiding this comment.
It had actually copied the pattern from the Windows stand_gui.cpp file, so guessing we could update that one as well?
1070 - if (p->p_info.ship_class >= 0 && p->p_info.ship_class < static_cast<int>(Ship_info.size())) {
1070 + if (p->p_info.ship_class >= 0 && p->p_info.ship_class < ship_info_size()) {
Went ahead and pushed a version with that change made.
…ction 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 bounds check using ship_info_size(), matching the pattern used elsewhere in the codebase. Also update the Windows standalone GUI to use ship_info_size() for consistency. Fixes scp-fs2open#7366 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
98e59d5 to
32f3369
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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