Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: [Network] don't rebuild the host-list during iterating the list #9240

Merged
merged 1 commit into from May 11, 2021

Conversation

TrueBrain
Copy link
Member

Motivation / Problem

I noticed random string-errors when opening the GUI with more than 1 server. It turns out, we were changing a list while iterating it. Although this went fine, the std::string used from the list was free'd, causing invalid reads.

It is a bit timing depending, so reproducing it isn't always as easy.

Description

Additionally, only rebuild it when we added a new manual server,
as otherwise it is a noop anyway.

Limitations

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

Additionally, only rebuild it when we added a new manual server,
as otherwise it is a noop anyway.
Copy link
Contributor

@rubidium42 rubidium42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the emscripten bit at the end of network.cpp require an update, so the host lists (for the config) is updated?

@TrueBrain
Copy link
Member Author

Does the emscripten bit at the end of network.cpp require an update, so the host lists (for the config) is updated?

No, those are never added as manual servers. I did that, as the idea is that the emscripten adds them every time you start the game, so they are already persistent in that sense.

@TrueBrain TrueBrain merged commit 9e7e87c into OpenTTD:master May 11, 2021
@TrueBrain TrueBrain deleted the network-add-server-rebuild branch May 11, 2021 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants