Skip to content

Commit fdc3293

Browse files
Document assumptions that are being made to avoid NULL pointer dereferences
1 parent 6866b49 commit fdc3293

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

src/qt/walletframe.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "bitcoingui.h"
88
#include "walletview.h"
99

10+
#include <cassert>
1011
#include <cstdio>
1112

1213
#include <QHBoxLayout>
@@ -69,6 +70,7 @@ bool WalletFrame::setCurrentWallet(const QString& name)
6970

7071
WalletView *walletView = mapWalletViews.value(name);
7172
walletStack->setCurrentWidget(walletView);
73+
assert(walletView);
7274
walletView->updateEncryptionStatus();
7375
return true;
7476
}

src/validation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,6 +1710,7 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
17101710
// before the first had been spent. Since those coinbases are sufficiently buried its no longer possible to create further
17111711
// duplicate transactions descending from the known pairs either.
17121712
// 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.
1713+
assert(pindex->pprev);
17131714
CBlockIndex *pindexBIP34height = pindex->pprev->GetAncestor(chainparams.GetConsensus().BIP34Height);
17141715
//Only continue to enforce if we're below BIP34 activation height or the block hash at that height doesn't correspond.
17151716
fEnforceBIP30 = fEnforceBIP30 && (!pindexBIP34height || !(pindexBIP34height->GetBlockHash() == chainparams.GetConsensus().BIP34Hash));
@@ -1849,6 +1850,7 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
18491850
if (!pblocktree->WriteTxIndex(vPos))
18501851
return AbortNode(state, "Failed to write transaction index");
18511852

1853+
assert(pindex->phashBlock);
18521854
// add this block to the view's block chain
18531855
view.SetBestBlock(pindex->GetBlockHash());
18541856

src/wallet/wallet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ void CWallet::SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator> ran
519519
const uint256& hash = it->second;
520520
CWalletTx* copyTo = &mapWallet[hash];
521521
if (copyFrom == copyTo) continue;
522+
assert(copyFrom && "Oldest wallet transaction in range assumed to have been found.");
522523
if (!copyFrom->IsEquivalentTo(*copyTo)) continue;
523524
copyTo->mapValue = copyFrom->mapValue;
524525
copyTo->vOrderForm = copyFrom->vOrderForm;

0 commit comments

Comments
 (0)