From bd2608270532b3dc85576ca22d691c935484675a Mon Sep 17 00:00:00 2001 From: mingda Date: Wed, 8 Jul 2020 17:59:57 +0800 Subject: [PATCH] [audit]#8 handle sqrt coner case --- contracts/lib/SafeMath.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/lib/SafeMath.sol b/contracts/lib/SafeMath.sol index 92eb396..8454b3a 100644 --- a/contracts/lib/SafeMath.sol +++ b/contracts/lib/SafeMath.sol @@ -53,7 +53,7 @@ library SafeMath { } function sqrt(uint256 x) internal pure returns (uint256 y) { - uint256 z = (x + 1) / 2; + uint256 z = add(x, 1) / 2; y = x; while (z < y) { y = z;