Skip to content

Commit a4a93a0

Browse files
committed
Merge #17906: gui: Set CConnman byte counters earlier to avoid uninitialized reads
8313fa8 gui: Set CConnman byte counters earlier to avoid uninitialized reads (Russell Yanofsky) Pull request description: 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 ACKs for top commit: MarcoFalke: ACK 8313fa8 promag: ACK 8313fa8. Tree-SHA512: 97c246da4e28e6e0b48f685b840f96746ad75c4b157a692201c6c4702db328a88ead8507d8e1b4e608aa1882513174ec60cf3977c31b7a9d76678cc9f49b45f8
2 parents 2ed74a4 + 8313fa8 commit a4a93a0

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)