mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-25 14:28:53 +02:00
Merge #11238: Add assertions before potential null deferences
c00199244 Fix potential null dereferences (MeshCollider)
Pull request description:
Picked up by the static analyzer [Facebook Infer](http://fbinfer.com/) which I was playing around with for another research project. Just adding some asserts before dereferencing potentially null pointers.
Tree-SHA512: 9c01dab2d21bce75c7c7ef867236654ab538318a1fb39f96f09cdd2382a05be1a6b2db0a1169a94168864e82ffeae0686a383db6eba799742bdd89c37ac74397
This commit is contained in:
@@ -814,6 +814,7 @@ static void ApplyStats(CCoinsStats &stats, CHashWriter& ss, const uint256& hash,
|
||||
static bool GetUTXOStats(CCoinsView *view, CCoinsStats &stats)
|
||||
{
|
||||
std::unique_ptr<CCoinsViewCursor> pcursor(view->Cursor());
|
||||
assert(pcursor);
|
||||
|
||||
CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
|
||||
stats.hashBlock = pcursor->GetBestBlock();
|
||||
@@ -1517,6 +1518,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");
|
||||
|
||||
Reference in New Issue
Block a user