diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2017-08-28 09:24:17 +0200 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2017-09-06 10:45:37 +0200 |
commit | fdc329376c8a0fa4dffd0cd2599a494a64c38472 (patch) | |
tree | 2e2052bb1fced6b82e6eb58adb64c7c9bf23fcf8 /src | |
parent | 6866b4912b8013ed748d12250209f7079a3c92e6 (diff) | |
download | bitcoin-fdc329376c8a0fa4dffd0cd2599a494a64c38472.tar.xz |
Document assumptions that are being made to avoid NULL pointer dereferences
Diffstat (limited to 'src')
-rw-r--r-- | src/qt/walletframe.cpp | 2 | ||||
-rw-r--r-- | src/validation.cpp | 2 | ||||
-rw-r--r-- | src/wallet/wallet.cpp | 1 |
3 files changed, 5 insertions, 0 deletions
diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp index f3183320f0..714a594318 100644 --- a/src/qt/walletframe.cpp +++ b/src/qt/walletframe.cpp @@ -7,6 +7,7 @@ #include "bitcoingui.h" #include "walletview.h" +#include <cassert> #include <cstdio> #include <QHBoxLayout> @@ -69,6 +70,7 @@ bool WalletFrame::setCurrentWallet(const QString& name) WalletView *walletView = mapWalletViews.value(name); walletStack->setCurrentWidget(walletView); + assert(walletView); walletView->updateEncryptionStatus(); return true; } diff --git a/src/validation.cpp b/src/validation.cpp index 3b9636839d..939921d677 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1710,6 +1710,7 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd // before the first had been spent. Since those coinbases are sufficiently buried its no longer possible to create further // duplicate transactions descending from the known pairs either. // If we're on the known chain at height greater than where BIP34 activated, we can save the db accesses needed for the BIP30 check. + assert(pindex->pprev); CBlockIndex *pindexBIP34height = pindex->pprev->GetAncestor(chainparams.GetConsensus().BIP34Height); //Only continue to enforce if we're below BIP34 activation height or the block hash at that height doesn't correspond. fEnforceBIP30 = fEnforceBIP30 && (!pindexBIP34height || !(pindexBIP34height->GetBlockHash() == chainparams.GetConsensus().BIP34Hash)); @@ -1849,6 +1850,7 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd if (!pblocktree->WriteTxIndex(vPos)) return AbortNode(state, "Failed to write transaction index"); + assert(pindex->phashBlock); // add this block to the view's block chain view.SetBestBlock(pindex->GetBlockHash()); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index d1d2060b0c..36d6ce0007 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -519,6 +519,7 @@ void CWallet::SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator> ran const uint256& hash = it->second; CWalletTx* copyTo = &mapWallet[hash]; if (copyFrom == copyTo) continue; + assert(copyFrom && "Oldest wallet transaction in range assumed to have been found."); if (!copyFrom->IsEquivalentTo(*copyTo)) continue; copyTo->mapValue = copyFrom->mapValue; copyTo->vOrderForm = copyFrom->vOrderForm; |