Skip to content

Commit

Permalink
net: fix unitialized values in CConnman
Browse files Browse the repository at this point in the history
This was only an issue in tests where CConnman::Start is not called.
  • Loading branch information
theuni committed Feb 23, 2017
1 parent bed5b30 commit 72aa332
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2165,6 +2165,11 @@ void CConnman::SetNetworkActive(bool active)
}

CConnman::CConnman(uint64_t nSeed0In, uint64_t nSeed1In) : nSeed0(nSeed0In), nSeed1(nSeed1In)
{
Init();
}

void CConnman::Init()
{
fNetworkActive = true;
setBannedIsDirty = false;
Expand All @@ -2180,6 +2185,10 @@ CConnman::CConnman(uint64_t nSeed0In, uint64_t nSeed1In) : nSeed0(nSeed0In), nSe
nBestHeight = 0;
clientInterface = NULL;
flagInterruptMsgProc = false;
nTotalBytesRecv = 0;
nTotalBytesSent = 0;
nMaxOutboundTotalBytesSentInCycle = 0;
nMaxOutboundCycleStartTime = 0;
}

NodeId CConnman::GetNewNodeId()
Expand All @@ -2189,10 +2198,7 @@ NodeId CConnman::GetNewNodeId()

bool CConnman::Start(CScheduler& scheduler, std::string& strNodeError, Options connOptions)
{
nTotalBytesRecv = 0;
nTotalBytesSent = 0;
nMaxOutboundTotalBytesSentInCycle = 0;
nMaxOutboundCycleStartTime = 0;
Init();

nRelevantServices = connOptions.nRelevantServices;
nLocalServices = connOptions.nLocalServices;
Expand Down
1 change: 1 addition & 0 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ class CConnman
void AcceptConnection(const ListenSocket& hListenSocket);
void ThreadSocketHandler();
void ThreadDNSAddressSeed();
void Init();

uint64_t CalculateKeyedNetGroup(const CAddress& ad) const;

Expand Down

0 comments on commit 72aa332

Please sign in to comment.