From 8313fa8e8112e429e104b7e7fd48e5e6e359b82e Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Fri, 10 Jan 2020 14:55:10 -0500 Subject: gui: Set CConnman byte counters earlier to avoid uninitialized reads Initialize CConnman byte counters during construction, so GetTotalBytesRecv() and GetTotalBytesSent() methods don't return garbage before Start() is called. Change shouldn't have any effect outside of the GUI. It just fixes a race condition during a qt test that was observed on travis: https://travis-ci.org/bitcoin/bitcoin/jobs/634989685 --- src/net.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/net.h b/src/net.h index 9cd3b769ec..a69c68e43a 100644 --- a/src/net.h +++ b/src/net.h @@ -386,8 +386,8 @@ private: // Network usage totals CCriticalSection cs_totalBytesRecv; CCriticalSection cs_totalBytesSent; - uint64_t nTotalBytesRecv GUARDED_BY(cs_totalBytesRecv); - uint64_t nTotalBytesSent GUARDED_BY(cs_totalBytesSent); + uint64_t nTotalBytesRecv GUARDED_BY(cs_totalBytesRecv) {0}; + uint64_t nTotalBytesSent GUARDED_BY(cs_totalBytesSent) {0}; // outbound limit & stats uint64_t nMaxOutboundTotalBytesSentInCycle GUARDED_BY(cs_totalBytesSent); -- cgit v1.2.3