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.
This commit is contained in:
Jonathan G Rennison
2020-05-06 23:23:03 +01:00
committed by Charles Pigott
parent 9aca6ff971
commit 1ac0d4a5b2
6 changed files with 28 additions and 23 deletions

View File

@@ -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();
/**