Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't initialize variables with default value #122

Closed
code423n4 opened this issue Dec 15, 2021 · 1 comment
Closed

Don't initialize variables with default value #122

code423n4 opened this issue Dec 15, 2021 · 1 comment
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization)

Comments

@code423n4
Copy link
Contributor

Handle

pmerkleplant

Vulnerability details

Impact

If a variable is not initialized, it is assumed to have the default value.
Explicitly initalizing a variable with its default value costs unnecessary gas.

For more info, see Mudit Gupta's Blog at point "No need to initialize variables with default values".

Therefore, following variable declarations could be refactored:

./CreditLine/CreditLine.sol:484: for (uint256 _index = 0; _index < _strategyList.length; _index++)
./CreditLine/CreditLine.sol:662: for (uint256 _index = 0; _index < _strategyList.length; _index++)
./CreditLine/CreditLine.sol:738: for (uint256 _index = 0; _index < _strategyList.length; _index++)
./CreditLine/CreditLine.sol:812: uint256 _principalPaid = 0;
./CreditLine/CreditLine.sol:892: for (uint256 index = 0; index < _strategyList.length; index++)
./CreditLine/CreditLine.sol:959: for (uint256 index = 0; index < _strategyList.length; index++)
./Pool/Pool.sol:359: uint256 _collateralShares = 0;
./SavingsAccount/SavingsAccount.sol:289: for (uint256 i = 0; i < _strategyList.length; i++)
./SavingsAccount/SavingsAccount.sol:467: for (uint256 i = 0; i < _strategyList.length; i++)

Tools used

grep

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Dec 15, 2021
code423n4 added a commit that referenced this issue Dec 15, 2021
@ritik99 ritik99 added the duplicate This issue or pull request already exists label Jan 7, 2022
@ritik99
Copy link
Collaborator

ritik99 commented Jan 7, 2022

Duplicate of #36 since both issues are regarding unnecessary initializations. Hence the issue is the same although the location of the issue mentioned in both places is different

@ritik99 ritik99 closed this as completed Jan 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization)
Projects
None yet
Development

No branches or pull requests

2 participants