Fix use after free error in test code

This commit is contained in:
seelabs
2017-07-18 16:25:18 -04:00
parent 5ad49454f1
commit a79cb95c85

View File

@@ -125,10 +125,11 @@ private:
void
on_accept(error_code ec)
{
if(! acceptor_.is_open())
return;
if(ec)
// ec must be checked before `acceptor_` or the member variable may be
// accessed after the destructor has completed
if(ec || !acceptor_.is_open())
return;
static int id_ = 0;
std::thread{lambda{++id_, *this, std::move(sock_)}}.detach();
acceptor_.async_accept(sock_,