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/core/address.h | |
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/core/address.h')
-rw-r--r-- | src/network/core/address.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/network/core/address.h b/src/network/core/address.h index 980d7227d..65546818b 100644 --- a/src/network/core/address.h +++ b/src/network/core/address.h @@ -15,6 +15,8 @@ #include "../../string_func.h" #include "../../core/smallmap_type.hpp" +#include <string> + class NetworkAddress; typedef std::vector<NetworkAddress> NetworkAddressList; ///< Type for a list of addresses. typedef SmallMap<NetworkAddress, SOCKET> SocketList; ///< Type for a mapping between address and socket. @@ -91,7 +93,7 @@ public: const char *GetHostname(); void GetAddressAsString(char *buffer, const char *last, bool with_family = true); - const char *GetAddressAsString(bool with_family = true); + std::string GetAddressAsString(bool with_family = true); const sockaddr_storage *GetAddress(); /** |