Browse Source

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
tags/v0.15.1
Chris Stewart 4 years ago
parent
commit
8276e70de1
2 changed files with 5 additions and 0 deletions
  1. 3
    0
      src/merkleblock.cpp
  2. 2
    0
      src/merkleblock.h

+ 3
- 0
src/merkleblock.cpp View File

@@ -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];

+ 2
- 0
src/merkleblock.h View File

@@ -121,6 +121,8 @@ public:
/**
* Used to relay blocks as header + vector<merkle branch>
* to filtered nodes.
*
* NOTE: The class assumes that the given CBlock has *at least* 1 transaction. If the CBlock has 0 txs, it will hit an assertion.
*/
class CMerkleBlock
{

Loading…
Cancel
Save