aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/chain.cpp
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2020-04-15 17:07:44 -0400
committerRussell Yanofsky <russ@yanofsky.org>2020-04-15 17:07:44 -0400
commit9986608ba93de040490ee0d5584ea33e605f1df0 (patch)
tree1777a14d9a81dc6dbdb1314c29f139c76738d2f9 /src/interfaces/chain.cpp
parent4bd6bc5cb4f3c4b017cc0ac21c00c2218acb97d0 (diff)
test: Verify findCommonAncestor always initializes outputs
Also add code comment to clarify surprising code noted by practicalswift https://github.com/bitcoin/bitcoin/pull/18657#issuecomment-614278450
Diffstat (limited to 'src/interfaces/chain.cpp')
-rw-r--r--src/interfaces/chain.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp
index c8311b2986..0e7641ae32 100644
--- a/src/interfaces/chain.cpp
+++ b/src/interfaces/chain.cpp
@@ -275,6 +275,8 @@ public:
const CBlockIndex* block1 = LookupBlockIndex(block_hash1);
const CBlockIndex* block2 = LookupBlockIndex(block_hash2);
const CBlockIndex* ancestor = block1 && block2 ? LastCommonAncestor(block1, block2) : nullptr;
+ // Using & instead of && below to avoid short circuiting and leaving
+ // output uninitialized.
return FillBlock(ancestor, ancestor_out, lock) & FillBlock(block1, block1_out, lock) & FillBlock(block2, block2_out, lock);
}
void findCoins(std::map<COutPoint, Coin>& coins) override { return FindCoins(m_node, coins); }