StartClient(): Make a local copy of server_name.

Previously we just held onto the const char* provided by the user.
This does not work in cases such as Java which provide a temporary
string.
This commit is contained in:
Peter Johnson
2015-08-29 00:07:10 -07:00
parent e516200e09
commit 7565207242

View File

@@ -26,8 +26,11 @@ void Dispatcher::StartServer(StringRef persist_filename,
}
void Dispatcher::StartClient(const char* server_name, unsigned int port) {
DispatcherBase::StartClient(std::bind(&TCPConnector::connect, server_name,
static_cast<int>(port), 1));
std::string server_name_copy(server_name);
DispatcherBase::StartClient([=]() -> std::unique_ptr<NetworkStream> {
return TCPConnector::connect(server_name_copy.c_str(),
static_cast<int>(port), 1);
});
}
Dispatcher::Dispatcher()