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 load array element twice #121

Closed
code423n4 opened this issue Dec 15, 2021 · 2 comments
Closed

Don't load array element twice #121

code423n4 opened this issue Dec 15, 2021 · 2 comments
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

Using a local variable instead of loading an array element twice circumvents
a second array boundary check and saves gas.

Therefore, the following functions could be refactored by using a local
variable for the array element:

CreditLine::_transferCollateral
CreditLine::calculateTotalCollateralTokens
CreditLine::_repayFromSavingsAccount
CreditLine::_withdrawBorrowAmount
CreditLine::_depositCollateralFromSavingsAccount (local variable not used in line 487)
SavingsAccount::getTotalTokens
SavingsAccount::withdrawAll
@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 sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label Dec 25, 2021
@ritik99 ritik99 added duplicate This issue or pull request already exists and removed sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") labels Dec 25, 2021
@ritik99
Copy link
Collaborator

ritik99 commented Dec 25, 2021

Duplicate of #157

@ritik99 ritik99 marked this as a duplicate of #157 Dec 25, 2021
@ritik99 ritik99 closed this as completed Dec 25, 2021
@0xean
Copy link
Collaborator

0xean commented Jan 22, 2022

duplicate of #21 not 157

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

3 participants