diff --git a/contracts/utils/cryptography/MerkleProof.sol b/contracts/utils/cryptography/MerkleProof.sol index dce05a0dc05..0745746f61b 100644 --- a/contracts/utils/cryptography/MerkleProof.sol +++ b/contracts/utils/cryptography/MerkleProof.sol @@ -50,7 +50,8 @@ library MerkleProof { */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; - for (uint256 i = 0; i < proof.length; i++) { + uint256 len = proof.length; + for (uint256 i = 0; i < len; i++) { computedHash = Hashes.commutativeKeccak256(computedHash, proof[i]); } return computedHash; @@ -61,7 +62,8 @@ library MerkleProof { */ function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; - for (uint256 i = 0; i < proof.length; i++) { + uint256 len = proof.length; + for (uint256 i = 0; i < len; i++) { computedHash = Hashes.commutativeKeccak256(computedHash, proof[i]); } return computedHash;