Open code423n4 opened 2 years ago
Meta0xNull
The local variable used as for loop index need not be initialized to 0 because the default value is 0. Avoiding this anti-pattern can save a few opcodes and therefore a tiny bit of gas.
https://github.com/Badger-Finance/badger-ibbtc-utility-zaps/blob/6f700995129182fec81b772f97abab9977b46026/contracts/IbbtcVaultZap.sol#L149 https://github.com/Badger-Finance/ibbtc/blob/d8b95e8d145eb196ba20033267a9ba43a17be02c/contracts/Zap.sol#L70
Manual Review
Remove explicit 0 initialization of for loop index variable.
Before: for (uint256 i = 0;
After for (uint256 i;
Agree with finding
Handle
Meta0xNull
Vulnerability details
Impact
The local variable used as for loop index need not be initialized to 0 because the default value is 0. Avoiding this anti-pattern can save a few opcodes and therefore a tiny bit of gas.
Proof of Concept
https://github.com/Badger-Finance/badger-ibbtc-utility-zaps/blob/6f700995129182fec81b772f97abab9977b46026/contracts/IbbtcVaultZap.sol#L149 https://github.com/Badger-Finance/ibbtc/blob/d8b95e8d145eb196ba20033267a9ba43a17be02c/contracts/Zap.sol#L70
Tools Used
Manual Review
Recommended Mitigation Steps
Remove explicit 0 initialization of for loop index variable.
Before: for (uint256 i = 0;
After for (uint256 i;