code-423n4 / 2021-10-pooltogether-findings

0 stars 0 forks source link

`PrizePool.sol#setTicket()` Remove unnecessary variable can make the code simpler and save some gas #36

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

WatchPug

Vulnerability details

https://github.com/pooltogether/v4-core/blob/055335bf9b09e3f4bbe11a788710dd04d827bf37/contracts/prize-pool/PrizePool.sol#L284-L297

function setTicket(ITicket _ticket) external override onlyOwner returns (bool) {
    address _ticketAddress = address(_ticket);

    require(_ticketAddress != address(0), "PrizePool/ticket-not-zero-address");
...

_ticketAddress is unnecessary as it's being used only once.

Recommendation

Change to:

function setTicket(ITicket _ticket) external override onlyOwner returns (bool) {
    require(address(_ticket) != address(0), "PrizePool/ticket-not-zero-address");
...
PierrickGT commented 3 years ago

PR: https://github.com/pooltogether/v4-core/pull/219

GalloDaSballo commented 3 years ago

Sponsor has mitigated