Skip to content
Snippets Groups Projects
Commit 2941237d authored by Sébastien Blin's avatar Sébastien Blin Committed by Adrien Béraud
Browse files

swarm_manager: avoid use-after-free

routing_table.hasNode() may occur while routing_table.removeNode()
is called, causing a use-after-free.
Avoid this

Change-Id: I84c8ac87716ea4abf64ad41de85985d242161f34
parent 8a42f969
Branches
No related tags found
No related merge requests found
......@@ -90,11 +90,10 @@ SwarmManager::addChannel(const std::shared_ptr<dhtnet::ChannelSocketInterface>&
void
SwarmManager::removeNode(const NodeId& nodeId)
{
std::unique_lock<std::mutex> lk(mutex);
if (isConnectedWith(nodeId)) {
{
std::lock_guard<std::mutex> lock(mutex);
removeNodeInternal(nodeId);
}
removeNodeInternal(nodeId);
lk.unlock();
maintainBuckets();
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment