mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-29 15:23:26 +02:00
Change CChain::Contains() to take reference
The `CChain::Contains()` method dereferences its input without checking, potentially resulting in nullptr-dereference if invoked with `nullptr`. To avoid this possibility, its input is changed to a reference instead. Call sites are adapted accoringly, extra nullptr-check is added as needed.
This commit is contained in:
@@ -73,7 +73,7 @@ static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue&
|
||||
entry.pushKV("blockhash", hashBlock.GetHex());
|
||||
const CBlockIndex* pindex = active_chainstate.m_blockman.LookupBlockIndex(hashBlock);
|
||||
if (pindex) {
|
||||
if (active_chainstate.m_chain.Contains(pindex)) {
|
||||
if (active_chainstate.m_chain.Contains(*pindex)) {
|
||||
entry.pushKV("confirmations", 1 + active_chainstate.m_chain.Height() - pindex->nHeight);
|
||||
entry.pushKV("time", pindex->GetBlockTime());
|
||||
entry.pushKV("blocktime", pindex->GetBlockTime());
|
||||
@@ -336,7 +336,7 @@ static RPCMethod getrawtransaction()
|
||||
UniValue result(UniValue::VOBJ);
|
||||
if (blockindex) {
|
||||
LOCK(cs_main);
|
||||
result.pushKV("in_active_chain", chainman.ActiveChain().Contains(blockindex));
|
||||
result.pushKV("in_active_chain", chainman.ActiveChain().Contains(*blockindex));
|
||||
}
|
||||
// If request is verbosity >= 1 but no blockhash was given, then look up the blockindex
|
||||
if (request.params[2].isNull()) {
|
||||
|
||||
Reference in New Issue
Block a user