Defensive handling of dead path (#13)
This commit is contained in:
parent
df7c2c538a
commit
b236ce7a9a
|
@ -121,11 +121,14 @@ contract DepositContract is IDepositContract {
|
||||||
for (uint height = 0; height < DEPOSIT_CONTRACT_TREE_DEPTH; height++) {
|
for (uint height = 0; height < DEPOSIT_CONTRACT_TREE_DEPTH; height++) {
|
||||||
if ((size & 1) == 1) {
|
if ((size & 1) == 1) {
|
||||||
branch[height] = node;
|
branch[height] = node;
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
node = sha256(abi.encodePacked(branch[height], node));
|
node = sha256(abi.encodePacked(branch[height], node));
|
||||||
size /= 2;
|
size /= 2;
|
||||||
}
|
}
|
||||||
|
// As the loop should always end prematurely with the `return` statement,
|
||||||
|
// this code should be unreachable. We assert `false` just to be safe.
|
||||||
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function to_little_endian_64(uint64 value) internal pure returns (bytes memory ret) {
|
function to_little_endian_64(uint64 value) internal pure returns (bytes memory ret) {
|
||||||
|
|
Loading…
Reference in New Issue