Increment node refcount before adding to vector (#1304)

This commit is contained in:
Tim Flynn 2017-02-02 03:22:47 -05:00 committed by UdjinM6
parent 944420deb0
commit a73185d939

View File

@ -429,15 +429,15 @@ CNode* ConnectNode(CAddress addrConnect, const char *pszDest, bool fConnectToMas
// Add node // Add node
CNode* pnode = new CNode(hSocket, addrConnect, pszDest ? pszDest : "", false, true); CNode* pnode = new CNode(hSocket, addrConnect, pszDest ? pszDest : "", false, true);
LOCK(cs_vNodes);
vNodes.push_back(pnode);
pnode->nTimeConnected = GetTime(); pnode->nTimeConnected = GetTime();
if(fConnectToMasternode) { if(fConnectToMasternode) {
pnode->AddRef(); pnode->AddRef();
pnode->fMasternode = true; pnode->fMasternode = true;
} }
LOCK(cs_vNodes);
vNodes.push_back(pnode);
return pnode; return pnode;
} else if (!proxyConnectionFailed) { } else if (!proxyConnectionFailed) {
// If connecting to the node failed, and failure is not caused by a problem connecting to // If connecting to the node failed, and failure is not caused by a problem connecting to