Skip to content

Commit acb3c72

Browse files
committed
Add require statement to protect from returning an invalid value
1 parent 9729b4f commit acb3c72

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

contracts/tree.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ library PartialMerkleTree {
8888
return getValue(tree, _findNode(tree, key));
8989
}
9090

91-
function safeGet(Tree storage tree, bytes key) internal view returns (bytes) {
91+
function safeGet(Tree storage tree, bytes key) internal view returns (bytes value) {
9292
bytes32 valueHash = _findNode(tree, key);
9393
require(valueHash != bytes32(0));
94-
return getValue(tree, valueHash);
94+
value = getValue(tree, valueHash);
95+
require(valueHash == keccak256(value));
9596
}
9697

9798
function doesInclude(Tree storage tree, bytes key) internal view returns (bool) {

0 commit comments

Comments
 (0)