From 7a8910443cda4f1801d4a0e72665b6b5ab0772a7 Mon Sep 17 00:00:00 2001 From: Ilya Savinov Date: Mon, 25 Sep 2017 17:16:56 +0300 Subject: [PATCH] Fix unlocked access to vNodes.size() (#1654) --- src/net.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 6eb6c8b8c..a9d02efd6 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1170,8 +1170,13 @@ void CConnman::ThreadSocketHandler() } } } - if(vNodes.size() != nPrevNodeCount) { - nPrevNodeCount = vNodes.size(); + size_t vNodesSize; + { + LOCK(cs_vNodes); + vNodesSize = vNodes.size(); + } + if(vNodesSize != nPrevNodeCount) { + nPrevNodeCount = vNodesSize; if(clientInterface) clientInterface->NotifyNumConnectionsChanged(nPrevNodeCount); }