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

0 stars 0 forks source link

Gas: Default case of `_calculateTierIndex` can return `0` #20

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

cmichel

Vulnerability details

If all masks match the DrawCalculator._calculateTierIndex function returns masksLength - numberOfMatches but it will always be zero at this point as masksLength == numberOfMatches. So just returning zero here would lead to saving a checked subtraction.

PierrickGT commented 3 years ago

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

GalloDaSballo commented 3 years ago

The sponsor has implemented the optimization in a subsequent PR