mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-13 00:00:23 +02:00
Change CChain::Next() to take reference
To minimize chance of erroneous nullptr dereference, `CChain::Next()` is changed to take a reference instead of a pointer. Call sites have been adapted. Notably, NextSyncBlock() now checks the FindFork() result before calling into Next(), because the fork lookup may return null.
This commit is contained in:
@@ -230,7 +230,7 @@ static bool rest_headers(const std::any& context,
|
||||
if (headers.size() == *parsed_count) {
|
||||
break;
|
||||
}
|
||||
pindex = active_chain.Next(pindex);
|
||||
pindex = active_chain.Next(*pindex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -556,7 +556,7 @@ static bool rest_filter_header(const std::any& context, HTTPRequest* req, const
|
||||
headers.push_back(pindex);
|
||||
if (headers.size() == *parsed_count)
|
||||
break;
|
||||
pindex = active_chain.Next(pindex);
|
||||
pindex = active_chain.Next(*pindex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user