Skip to content

Commit

Permalink
Fix use after free error in test code
Browse files Browse the repository at this point in the history
  • Loading branch information
seelabs committed Jul 31, 2017
1 parent 5ad4945 commit a79cb95
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/test/app/ValidatorSite_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@ class http_sync_server
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_,
Expand Down

0 comments on commit a79cb95

Please sign in to comment.