diff options
author | Derek Chiang <derekchiang93@gmail.com> | 2017-09-25 16:36:13 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2017-09-25 16:36:13 +0800 |
commit | d6a6180366e613deaa5ce9c36e80bb0fac5430f6 (patch) | |
tree | cd1f4a0dd73c6dc3e88a6949ea25ee7cc2685306 | |
parent | 9feec51e2dd754819e5c730ac5985d28d57adb48 (diff) | |
download | go-tangerine-d6a6180366e613deaa5ce9c36e80bb0fac5430f6.tar.gz go-tangerine-d6a6180366e613deaa5ce9c36e80bb0fac5430f6.tar.zst go-tangerine-d6a6180366e613deaa5ce9c36e80bb0fac5430f6.zip |
contracts/chequebook: fix two contract issues (#15086)
This patch fixes the following issues:
* The contract executes send() when it does not have enough balance.
* The contract always sends a total amount of zero.
-rw-r--r-- | contracts/chequebook/contract/chequebook.sol | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/contracts/chequebook/contract/chequebook.sol b/contracts/chequebook/contract/chequebook.sol index eefe6c063..845ba464b 100644 --- a/contracts/chequebook/contract/chequebook.sol +++ b/contracts/chequebook/contract/chequebook.sol @@ -27,10 +27,11 @@ contract chequebook is mortal { if(owner != ecrecover(hash, sig_v, sig_r, sig_s)) return; // Attempt sending the difference between the cumulative amount on the cheque // and the cumulative amount on the last cashed cheque to beneficiary. - if (amount - sent[beneficiary] >= this.balance) { + uint256 diff = amount - sent[beneficiary]; + if (diff <= this.balance) { // update the cumulative amount before sending sent[beneficiary] = amount; - if (!beneficiary.send(amount - sent[beneficiary])) { + if (!beneficiary.send(diff)) { // Upon failure to execute send, revert everything throw; } |