aboutsummaryrefslogtreecommitdiff
path: root/src/merkleblock.cpp
diff options
context:
space:
mode:
authorChris Stewart <stewart.chris1234@gmail.com>2017-04-06 20:28:19 -0500
committerChris Stewart <stewart.chris1234@gmail.com>2017-07-12 10:48:37 -0500
commit8276e70de15c5c3a7525471ad619edd1237b424a (patch)
tree2a64138670f3166868cc565b8f739c2cf5b11f61 /src/merkleblock.cpp
parente8b95239eeb052b122786d9cca6bc58106837599 (diff)
downloadbitcoin-8276e70de15c5c3a7525471ad619edd1237b424a.tar.xz
Adding assert to avoid a memory access violation inside of PartialMerkleTree::CalcHash()
Adding comment to assert in PartialMerkleTree::CalcHash() Adding comment on CMerkleBlock indicating it calls something that contains an assert Removing EOL whitespace
Diffstat (limited to 'src/merkleblock.cpp')
-rw-r--r--src/merkleblock.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/merkleblock.cpp b/src/merkleblock.cpp
index 78d7cd6001..55f899b649 100644
--- a/src/merkleblock.cpp
+++ b/src/merkleblock.cpp
@@ -59,6 +59,9 @@ CMerkleBlock::CMerkleBlock(const CBlock& block, const std::set<uint256>& txids)
}
uint256 CPartialMerkleTree::CalcHash(int height, unsigned int pos, const std::vector<uint256> &vTxid) {
+ //we can never have zero txs in a merkle block, we always need the coinbase tx
+ //if we do not have this assert, we can hit a memory access violation when indexing into vTxid
+ assert(vTxid.size() != 0);
if (height == 0) {
// hash at height 0 is the txids themself
return vTxid[pos];