Skip to content

Commit

Permalink
bugfix: Whenever deleting m_log, verify that it is not null. Change t…
Browse files Browse the repository at this point in the history
…o null after delete.

This fixes a double-free in cases of inheritance.
  • Loading branch information
CFSworks committed Nov 9, 2014
1 parent 3329597 commit e1e2eb1
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/clientagent/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ Client::Client(ClientAgent* client_agent) : m_client_agent(client_agent)

Client::~Client()
{
delete m_log;
if(m_log) {
delete m_log;
m_log = nullptr;
}
}

void Client::annihilate()
Expand Down
5 changes: 4 additions & 1 deletion src/clientagent/ClientAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ ClientAgent::ClientAgent(RoleConfig roleconfig) : Role(roleconfig), m_net_accept

ClientAgent::~ClientAgent()
{
delete m_log;
if(m_log) {
delete m_log;
m_log = nullptr;
}
}

// handle_tcp generates a new Client object from a raw tcp connection.
Expand Down
5 changes: 4 additions & 1 deletion src/stateserver/DBStateServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ DBStateServer::DBStateServer(RoleConfig roleconfig) : StateServer(roleconfig),

DBStateServer::~DBStateServer()
{
delete m_log;
if(m_log) {
delete m_log;
m_log = nullptr;
}
}

void DBStateServer::handle_datagram(DatagramHandle, DatagramIterator &dgi)
Expand Down
5 changes: 4 additions & 1 deletion src/stateserver/DistributedObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ DistributedObject::DistributedObject(StateServer *stateserver, channel_t sender,

DistributedObject::~DistributedObject()
{
delete m_log;
if(m_log) {
delete m_log;
m_log = nullptr;
}
}

void DistributedObject::append_required_data(DatagramPtr dg, bool client_only, bool also_owner)
Expand Down
5 changes: 4 additions & 1 deletion src/stateserver/LoadingObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ LoadingObject::LoadingObject(DBStateServer *stateserver, doid_t do_id, doid_t pa

LoadingObject::~LoadingObject()
{
delete m_log;
if(m_log) {
delete m_log;
m_log = nullptr;
}
}

void LoadingObject::begin()
Expand Down
5 changes: 4 additions & 1 deletion src/stateserver/StateServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ StateServer::StateServer(RoleConfig roleconfig) : Role(roleconfig)

StateServer::~StateServer()
{
delete m_log;
if(m_log) {
delete m_log;
m_log = nullptr;
}
}

void StateServer::handle_generate(DatagramIterator &dgi, bool has_other)
Expand Down

0 comments on commit e1e2eb1

Please sign in to comment.