From 4652791141f0a8a977b324147ccf1a2360b69ca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Barbosa?= Date: Thu, 13 Jul 2017 23:25:56 +0100 Subject: [PATCH] Fix uninitialized atomic variables --- src/netbase.cpp | 2 +- src/wallet/db.h | 4 ++-- src/wallet/walletdb.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/netbase.cpp b/src/netbase.cpp index a23f92e1e..3fb1c18f0 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -563,7 +563,7 @@ static bool ConnectThroughProxy(const proxyType &proxy, const std::string& strDe // do socks negotiation if (proxy.randomize_credentials) { ProxyCredentials random_auth; - static std::atomic_int counter; + static std::atomic_int counter(0); random_auth.username = random_auth.password = strprintf("%i", counter++); if (!Socks5(strDest, (unsigned short)port, &random_auth, hSocket)) return false; diff --git a/src/wallet/db.h b/src/wallet/db.h index 7cccc6566..4f3ad0c42 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -95,13 +95,13 @@ class CWalletDBWrapper friend class CDB; public: /** Create dummy DB handle */ - CWalletDBWrapper() : nLastSeen(0), nLastFlushed(0), nLastWalletUpdate(0), env(nullptr) + CWalletDBWrapper() : nUpdateCounter(0), nLastSeen(0), nLastFlushed(0), nLastWalletUpdate(0), env(nullptr) { } /** Create DB handle to real database */ CWalletDBWrapper(CDBEnv *env_in, const std::string &strFile_in) : - nLastSeen(0), nLastFlushed(0), nLastWalletUpdate(0), env(env_in), strFile(strFile_in) + nUpdateCounter(0), nLastSeen(0), nLastFlushed(0), nLastWalletUpdate(0), env(env_in), strFile(strFile_in) { } diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index deb09a477..2a33dca24 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -747,7 +747,7 @@ DBErrors CWalletDB::ZapWalletTx(std::vector& vWtx) void MaybeCompactWalletDB() { - static std::atomic fOneThread; + static std::atomic fOneThread(false); if (fOneThread.exchange(true)) { return; }