Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

Use of a value already stored in a variable

Summary

The value of Soulmate::soulmateOf[msg.sender] in the Soulmate::getDivorced() function has already
been stored in the variable soulmate2. so to access this value you'd better go
through the variable containing it.

Vulnerability Details

function getDivorced() public {
address soulmate2 = soulmateOf[msg.sender];
divorced[msg.sender] = true;
@=> divorced[soulmateOf[msg.sender]] = true;
emit CoupleHasDivorced(msg.sender, soulmate2);
}

The value Soulmate::soulmateOf[msg.sender] is already stored in the variable soulmate2.
So to get this value you just need to call the variable that contains it.

Impact

High gas consumption

Tools Used

Foundry

Recommendations

Just call the soulmate2 variable wherever you want to use the value Soulmate::soulmateOf[msg.sender]
in the Soulmate::getDivorced() function.

function getDivorced() public {
address soulmate2 = soulmateOf[msg.sender];
divorced[msg.sender] = true;
- divorced[soulmateOf[msg.sender]] = true;
emit CoupleHasDivorced(msg.sender, soulmate2);
}
function getDivorced() public {
address soulmate2 = soulmateOf[msg.sender];
divorced[msg.sender] = true;
+ divorced[soulmate2] = true;
emit CoupleHasDivorced(msg.sender, soulmate2);
}
Updates

Lead Judging Commences

0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Other

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.