mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-09 11:27:28 -03:00
Check leaves size maximum in MerkleComputation
Belt and suspenders for future code changes. Currently this function is only called from TransactionMerklePath() which sets leaves to the block transactions, so the Assume always holds.
This commit is contained in:
parent
4d57288246
commit
f86678156a
1 changed files with 2 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <consensus/merkle.h>
|
||||
#include <hash.h>
|
||||
#include <util/check.h>
|
||||
|
||||
/* WARNING! If you're reading this because you're learning about crypto
|
||||
and/or designing a new system that will use merkle trees, keep in mind
|
||||
|
@ -87,6 +88,7 @@ uint256 BlockWitnessMerkleRoot(const CBlock& block, bool* mutated)
|
|||
static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot, bool* pmutated, uint32_t leaf_pos, std::vector<uint256>* path)
|
||||
{
|
||||
if (path) path->clear();
|
||||
Assume(leaves.size() <= UINT32_MAX);
|
||||
if (leaves.size() == 0) {
|
||||
if (pmutated) *pmutated = false;
|
||||
if (proot) *proot = uint256();
|
||||
|
|
Loading…
Reference in a new issue