transmissions11 / solmate

Modern, opinionated, and gas optimized building blocks for smart contract development.
GNU Affero General Public License v3.0
3.93k stars 645 forks source link

🐛 Fix edge case in SignedWadMath #380

Closed transmissions11 closed 1 year ago

transmissions11 commented 1 year ago

Description

"For "a*b" on signed integer, there is a specific edge case, where "a == -1", and "b == min int256", where "-b" does not fit into the representation, and thus the multiplication should revert (overflow)" - @montyly

Credit to @milotruck and @magnetto90 for discovering this bug!

Checklist

Ensure you completed all of the steps below before submitting your pull request:

Pull requests with an incomplete checklist will be thrown out.