diff options
author | Jonathan G Rennison <j.g.rennison@gmail.com> | 2020-05-06 23:23:03 +0100 |
---|---|---|
committer | Charles Pigott <charlespigott@googlemail.com> | 2020-06-21 11:47:56 +0100 |
commit | 1ac0d4a5b2c8f5e5c9a4629091c81e3f41a4c126 (patch) | |
tree | b6dddcdb1a067ca901e67d0ec126ad34aa3a37c5 /src/network/network_gui.cpp | |
parent | 9aca6ff971e95fbeaff9302cf5d8d44a80ed0206 (diff) | |
download | openttd-1ac0d4a5b2c8f5e5c9a4629091c81e3f41a4c126.tar.xz |
Fix: Thread unsafe use of NetworkAddress::GetAddressAsString
Remove static buffer form of NetworkAddress::GetAddressAsString.
This is used in multiple threads concurrently, and is not thread-safe.
Replace it with a form returning std::string.
Diffstat (limited to 'src/network/network_gui.cpp')
-rw-r--r-- | src/network/network_gui.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index c4488f35d..ab72d9521 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -664,7 +664,9 @@ public: DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_SERVER_VERSION); // server version y += FONT_HEIGHT_NORMAL; - SetDParamStr(0, sel->address.GetAddressAsString()); + char network_addr_buffer[NETWORK_HOSTNAME_LENGTH + 6 + 7]; + sel->address.GetAddressAsString(network_addr_buffer, lastof(network_addr_buffer)); + SetDParamStr(0, network_addr_buffer); DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_SERVER_LIST_SERVER_ADDRESS); // server address y += FONT_HEIGHT_NORMAL; |