From 872478367c2288adcb96b2b32285aa67a609049a Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Sat, 19 Oct 2019 22:12:25 +0300 Subject: [PATCH] Fix multiplication overflow throw because of non-existing short-circuit boolean expressions evaluation in Solidity Assembly --- src/jug.sol | 4 +++- src/pot.sol | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/jug.sol b/src/jug.sol index 44a6d22a..d055fa44 100644 --- a/src/jug.sol +++ b/src/jug.sol @@ -53,7 +53,9 @@ contract Jug is DSNote { x := div(xxRound, b) if mod(n,2) { let zx := mul(z, x) - if and(iszero(iszero(x)), iszero(eq(div(zx, x), z))) { revert(0,0) } + if iszero(iszero(x)) { + if iszero(eq(div(zx, x), z)) { revert(0,0) } + } let zxRound := add(zx, half) if lt(zxRound, zx) { revert(0,0) } z := div(zxRound, b) diff --git a/src/pot.sol b/src/pot.sol index e8c31016..88b30c9b 100644 --- a/src/pot.sol +++ b/src/pot.sol @@ -91,7 +91,9 @@ contract Pot is DSNote { x := div(xxRound, base) if mod(n,2) { let zx := mul(z, x) - if and(iszero(iszero(x)), iszero(eq(div(zx, x), z))) { revert(0,0) } + if iszero(iszero(x)) { + if iszero(eq(div(zx, x), z)) { revert(0,0) } + } let zxRound := add(zx, half) if lt(zxRound, zx) { revert(0,0) } z := div(zxRound, base)