Skip to content

Commit 95543d8

Browse files
[net] Avoid possibility of NULL pointer dereference in MarkBlockAsInFlight(...)
In the case that the branch ... if (itInFlight != mapBlocksInFlight.end() && itInFlight->second.first == nodeid) { ... is taken, there was prior to this commit an implicit assumption that MarkBlockAsInFlight(...) was being called with its fifth and optional argument (pit) being present (and non-NULL).
1 parent 02e5308 commit 95543d8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/net_processing.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,9 @@ bool MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, const Consensus::Pa
338338
// Short-circuit most stuff in case its from the same node
339339
map<uint256, pair<NodeId, list<QueuedBlock>::iterator> >::iterator itInFlight = mapBlocksInFlight.find(hash);
340340
if (itInFlight != mapBlocksInFlight.end() && itInFlight->second.first == nodeid) {
341-
*pit = &itInFlight->second.second;
341+
if (pit) {
342+
*pit = &itInFlight->second.second;
343+
}
342344
return false;
343345
}
344346

0 commit comments

Comments
 (0)