mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-13 14:13:52 +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:
@@ -2370,7 +2370,10 @@ bool StartIndexBackgroundSync(NodeContext& node)
|
||||
{
|
||||
LOCK(::cs_main);
|
||||
pindex = chainman.m_blockman.LookupBlockIndex(summary.best_block_hash);
|
||||
if (!index_chain.Contains(pindex)) {
|
||||
if (!pindex) {
|
||||
LogWarning("Failed to find block manager entry for best block %s from %s, falling back to genesis for index sync",
|
||||
summary.best_block_hash.ToString(), summary.name);
|
||||
} else if (!index_chain.Contains(*pindex)) {
|
||||
pindex = index_chain.FindFork(pindex);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user