diff options
author | João Barbosa <joao.paulo.barbosa@gmail.com> | 2020-09-20 00:25:45 +0100 |
---|---|---|
committer | João Barbosa <joao.paulo.barbosa@gmail.com> | 2020-11-07 11:40:27 +0000 |
commit | 9b74461fa293453a9eb0b1717b30b3f7fa778d91 (patch) | |
tree | 2ae37592647fffdcd69303dc8c1f3247fd3054a8 /src/wallet/wallet.h | |
parent | 021feb3187b207d511561c1f0ffd7f9e5e0c9c1d (diff) |
refactor: Assert before dereference in CWallet::GetDatabase
Diffstat (limited to 'src/wallet/wallet.h')
-rw-r--r-- | src/wallet/wallet.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 6ad75d3d69..5e23622e23 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -698,7 +698,7 @@ private: std::string m_name; /** Internal database handle. */ - std::unique_ptr<WalletDatabase> database; + std::unique_ptr<WalletDatabase> const m_database; /** * The following is used to keep track of how far behind the wallet is @@ -732,7 +732,11 @@ public: */ mutable RecursiveMutex cs_wallet; - WalletDatabase& GetDatabase() const override { return *database; } + WalletDatabase& GetDatabase() const override + { + assert(static_cast<bool>(m_database)); + return *m_database; + } /** * Select a set of coins such that nValueRet >= nTargetValue and at least @@ -754,7 +758,7 @@ public: CWallet(interfaces::Chain* chain, const std::string& name, std::unique_ptr<WalletDatabase> database) : m_chain(chain), m_name(name), - database(std::move(database)) + m_database(std::move(database)) { } |