Defensive handling of dead path (#13)

This commit is contained in:
MrChico 2020-05-13 15:46:58 +02:00 committed by GitHub
parent df7c2c538a
commit b236ce7a9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -121,11 +121,14 @@ contract DepositContract is IDepositContract {
for (uint height = 0; height < DEPOSIT_CONTRACT_TREE_DEPTH; height++) {
if ((size & 1) == 1) {
branch[height] = node;
break;
return;
}
node = sha256(abi.encodePacked(branch[height], node));
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) {