From 20009ecd029fa887a8a98122fa5df0ec5181cdb1 Mon Sep 17 00:00:00 2001 From: yjwxfq <112159687+yjwxfq@users.noreply.github.com> Date: Thu, 1 Jun 2023 14:17:22 +0800 Subject: [PATCH] Update token_contract.go, modify the overflow judgment condition for function add() Signed-off-by: yjwxfq <112159687+yjwxfq@users.noreply.github.com> --- token-erc-20/chaincode-go/chaincode/token_contract.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/token-erc-20/chaincode-go/chaincode/token_contract.go b/token-erc-20/chaincode-go/chaincode/token_contract.go index 836eeeb7..b6b7bad6 100644 --- a/token-erc-20/chaincode-go/chaincode/token_contract.go +++ b/token-erc-20/chaincode-go/chaincode/token_contract.go @@ -695,7 +695,7 @@ func add(b int, q int) (int, error) { var sum int sum = q + b - if (sum < q) == (b >= 0 && q >= 0) { + if (sum < q || sum < b) == (b >= 0 && q >= 0) { return 0, fmt.Errorf("Math: addition overflow occurred %d + %d", b, q) }