Merge pull request from GHSA-wprv-93r4-jj2p
This commit is contained in:
@ -121,10 +121,11 @@ library MerkleProof {
|
||||
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
|
||||
// the merkle tree.
|
||||
uint256 leavesLen = leaves.length;
|
||||
uint256 proofLen = proof.length;
|
||||
uint256 totalHashes = proofFlags.length;
|
||||
|
||||
// Check proof validity.
|
||||
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
|
||||
require(leavesLen + proofLen - 1 == totalHashes, "MerkleProof: invalid multiproof");
|
||||
|
||||
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
|
||||
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
|
||||
@ -146,6 +147,7 @@ library MerkleProof {
|
||||
}
|
||||
|
||||
if (totalHashes > 0) {
|
||||
require(proofPos == proofLen, "MerkleProof: invalid multiproof");
|
||||
unchecked {
|
||||
return hashes[totalHashes - 1];
|
||||
}
|
||||
@ -173,10 +175,11 @@ library MerkleProof {
|
||||
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
|
||||
// the merkle tree.
|
||||
uint256 leavesLen = leaves.length;
|
||||
uint256 proofLen = proof.length;
|
||||
uint256 totalHashes = proofFlags.length;
|
||||
|
||||
// Check proof validity.
|
||||
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
|
||||
require(leavesLen + proofLen - 1 == totalHashes, "MerkleProof: invalid multiproof");
|
||||
|
||||
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
|
||||
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
|
||||
@ -198,6 +201,7 @@ library MerkleProof {
|
||||
}
|
||||
|
||||
if (totalHashes > 0) {
|
||||
require(proofPos == proofLen, "MerkleProof: invalid multiproof");
|
||||
unchecked {
|
||||
return hashes[totalHashes - 1];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user