[audit]#8.1 handel sqrt coner case

This commit is contained in:
mingda
2020-07-10 13:34:04 +08:00
parent 7ead33bc37
commit f7bfead589

View File

@@ -53,7 +53,7 @@ library SafeMath {
} }
function sqrt(uint256 x) internal pure returns (uint256 y) { function sqrt(uint256 x) internal pure returns (uint256 y) {
uint256 z = add(x, 1) / 2; uint256 z = x / 2 + 1;
y = x; y = x;
while (z < y) { while (z < y) {
y = z; y = z;