aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorpracticalswift <practicalswift@users.noreply.github.com>2017-02-28 15:49:49 +0100
committerpracticalswift <practicalswift@users.noreply.github.com>2017-02-28 15:49:49 +0100
commit95543d8747cbf7c1945ac36c36031ae40152cf2f (patch)
tree94044a7d60dcf54024b0a4547d27076838570a8a /src/net_processing.cpp
parent02e5308c1b9f3771bbe49bc5036215fa2bd66aa9 (diff)
[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).
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 72c403a57e..521dd02ab8 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -338,7 +338,9 @@ bool MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, const Consensus::Pa
// Short-circuit most stuff in case its from the same node
map<uint256, pair<NodeId, list<QueuedBlock>::iterator> >::iterator itInFlight = mapBlocksInFlight.find(hash);
if (itInFlight != mapBlocksInFlight.end() && itInFlight->second.first == nodeid) {
- *pit = &itInFlight->second.second;
+ if (pit) {
+ *pit = &itInFlight->second.second;
+ }
return false;
}