diff --git a/src/miner.cpp b/src/miner.cpp index 68aa079b33f59..96060ccd6c374 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -136,6 +136,7 @@ std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& sc LOCK2(cs_main, mempool.cs); CBlockIndex* pindexPrev = chainActive.Tip(); + assert(pindexPrev != nullptr); nHeight = pindexPrev->nHeight + 1; bool fDIP0003Active_context = nHeight >= chainparams.GetConsensus().DIP0003Height; diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 548d42626114c..1acdb3777eb1f 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -337,6 +337,7 @@ bool MarkBlockAsReceived(const uint256& hash) { std::map::iterator> >::iterator itInFlight = mapBlocksInFlight.find(hash); if (itInFlight != mapBlocksInFlight.end()) { CNodeState *state = State(itInFlight->second.first); + assert(state != nullptr); state->nBlocksInFlightValidHeaders -= itInFlight->second.second->fValidatedHeaders; if (state->nBlocksInFlightValidHeaders == 0 && itInFlight->second.second->fValidatedHeaders) { // Last validated block on the queue was received. diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 3503dfb4d25d1..cd2f2269c7dd3 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1080,6 +1080,7 @@ static void ApplyStats(CCoinsStats &stats, CHashWriter& ss, const uint256& hash, static bool GetUTXOStats(CCoinsView *view, CCoinsStats &stats) { std::unique_ptr pcursor(view->Cursor()); + assert(pcursor); CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); stats.hashBlock = pcursor->GetBestBlock(); @@ -1815,6 +1816,8 @@ UniValue getchaintxstats(const JSONRPCRequest& request) pindex = chainActive.Tip(); } } + + assert(pindex != nullptr); if (blockcount < 1 || blockcount >= pindex->nHeight) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block count: should be between 1 and the block's height"); diff --git a/src/validation.cpp b/src/validation.cpp index 76dd35db4d598..461734d00956f 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -290,6 +290,8 @@ bool CheckSequenceLocks(const CTransaction &tx, int flags, LockPoints* lp, bool AssertLockHeld(mempool.cs); CBlockIndex* tip = chainActive.Tip(); + assert(tip != nullptr); + CBlockIndex index; index.pprev = tip; // CheckSequenceLocks() uses chainActive.Height()+1 to evaluate