Invalid detection of divide-before-multiply in if-else block
- Dominant language
- Python
- Stars
- 6.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
```
slither --version
0.7.1
```
Please consider the following code:
```
if (block.timestamp >= periodFinish) {
rewardRate = reward.div(DURATION);
} else {
// ...
uint256 leftover = remaining.mul(rewardRate);
// ...
}
```
Slither says:
```
RewardsPool.topUpReward(uint256) (contracts/RewardsPool.sol#28-45) performs a multiplication on the result of a division:
-rewardRate = reward.div(DURATION) (contracts/RewardsPool.sol#33)
-leftover = remaining.mul(rewardRate) (contracts/RewardsPool.sol#36)
```
Those two operations are in a separate if-else paths and should not affect each other.
Contributor guide
Assessment
This issue has not been assessed yet.