mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Fix use after free error in test code
This commit is contained in:
@@ -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_,
|
||||
|
||||
Reference in New Issue
Block a user