1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Fix various memory errors related to server and connections.

* keep connection when restarting scenario
* wrong double free in Connection
* multiple use after free when stopping server
* double free of StartInfo
This commit is contained in:
Karlis Senko
2018-04-30 18:09:48 +03:00
parent 69330de89c
commit 224ea28433
6 changed files with 49 additions and 49 deletions

View File

@@ -58,7 +58,7 @@ void CConnection::init()
}
CConnection::CConnection(std::string host, ui16 port, std::string Name, std::string UUID)
: iser(this), oser(this), io_service(std::make_shared<asio::io_service>()), connectionID(0), name(Name), uuid(UUID)
: io_service(std::make_shared<asio::io_service>()), iser(this), oser(this), name(Name), uuid(UUID), connectionID(0)
{
int i;
boost::system::error_code error = asio::error::host_not_found;
@@ -111,12 +111,12 @@ connerror1:
throw std::runtime_error("Can't establish connection :(");
}
CConnection::CConnection(std::shared_ptr<TSocket> Socket, std::string Name, std::string UUID)
: iser(this), oser(this), socket(Socket), io_service(&Socket->get_io_service()), connectionID(0), name(Name), uuid(UUID)
: iser(this), oser(this), socket(Socket), name(Name), uuid(UUID), connectionID(0)
{
init();
}
CConnection::CConnection(std::shared_ptr<TAcceptor> acceptor, std::shared_ptr<boost::asio::io_service> Io_service, std::string Name, std::string UUID)
: iser(this), oser(this), connectionID(0), name(Name), uuid(UUID)
CConnection::CConnection(std::shared_ptr<TAcceptor> acceptor, std::shared_ptr<boost::asio::io_service> io_service, std::string Name, std::string UUID)
: io_service(io_service), iser(this), oser(this), name(Name), uuid(UUID), connectionID(0)
{
boost::system::error_code error = asio::error::host_not_found;
socket = std::make_shared<tcp::socket>(*io_service);