Unnecessary "else if" in function vest (Vesting.sol) #22
Labels
bug
Something isn't working
G (Gas Optimization)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
ye0lde
Vulnerability details
Impact
The "else if(_isRevocable == 1)" is not needed and can be removed to save gas and improve code clarity.
Proof of Concept
The "_isRevocable" variable is guaranteed to be 0 or 1 here:
https://github.com/code-423n4/2021-11-bootfinance/blob/7c457b2b5ba6b2c887dafdf7428fd577e405d652/vesting/contracts/Vesting.sol#L77
But it is treated like it can have some other value here:
https://github.com/code-423n4/2021-11-bootfinance/blob/7c457b2b5ba6b2c887dafdf7428fd577e405d652/vesting/contracts/Vesting.sol#L83-L88
Tools Used
Visual Studio Code, Remix
Recommended Mitigation Steps
Rewrite these lines
https://github.com/code-423n4/2021-11-bootfinance/blob/7c457b2b5ba6b2c887dafdf7428fd577e405d652/vesting/contracts/Vesting.sol#L83-L88
to
benRevocable[_beneficiary] = (_isRevocable == 0) ? [false,false] : [true,false];
The text was updated successfully, but these errors were encountered: