From 2a2260de45925bc309b6d6baf990d5ea6a171a90 Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Tue, 18 Dec 2018 15:55:24 -0800 Subject: Use more efficient check for overflow --- .../protocol/contracts/protocol/AssetProxy/MultiAssetProxy.sol | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contracts/protocol/contracts/protocol/AssetProxy/MultiAssetProxy.sol b/contracts/protocol/contracts/protocol/AssetProxy/MultiAssetProxy.sol index b42aa79ee..4285725d0 100644 --- a/contracts/protocol/contracts/protocol/AssetProxy/MultiAssetProxy.sol +++ b/contracts/protocol/contracts/protocol/AssetProxy/MultiAssetProxy.sol @@ -181,11 +181,11 @@ contract MultiAssetProxy is let amountsElement := calldataload(add(amountsContentsStart, i)) let totalAmount := mul(amountsElement, amount) - // Revert if multiplication resulted in an overflow - if and( - gt(amount, 0), - iszero(eq(div(totalAmount, amount), amountsElement)) - ) { + // Revert if `amount` != 0 and multiplication resulted in an overflow + if iszero(or( + iszero(amount), + eq(div(totalAmount, amount), amountsElement) + )) { // Revert with `Error("UINT256_OVERFLOW")` mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000) mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000) -- cgit