Skip to content

Commit 8313fa8

Browse files
committed
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
1 parent e7f8450 commit 8313fa8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/net.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ class CConnman
386386
// Network usage totals
387387
CCriticalSection cs_totalBytesRecv;
388388
CCriticalSection cs_totalBytesSent;
389-
uint64_t nTotalBytesRecv GUARDED_BY(cs_totalBytesRecv);
390-
uint64_t nTotalBytesSent GUARDED_BY(cs_totalBytesSent);
389+
uint64_t nTotalBytesRecv GUARDED_BY(cs_totalBytesRecv) {0};
390+
uint64_t nTotalBytesSent GUARDED_BY(cs_totalBytesSent) {0};
391391

392392
// outbound limit & stats
393393
uint64_t nMaxOutboundTotalBytesSentInCycle GUARDED_BY(cs_totalBytesSent);

0 commit comments

Comments
 (0)