Fix balance and allowance checks in _burn and _burnFrom (#1218)

* fix off by one error in _burn and _burnFrom

* add tests for off-by-one error

* change amount used
This commit is contained in:
Francisco Giordano
2018-08-17 19:18:05 -03:00
committed by GitHub
parent 20cf885430
commit 7618b91d9c
2 changed files with 63 additions and 55 deletions

View File

@ -178,7 +178,7 @@ contract StandardToken is ERC20 {
*/
function _burn(address _account, uint256 _amount) internal {
require(_account != 0);
require(balances[_account] > _amount);
require(_amount <= balances[_account]);
totalSupply_ = totalSupply_.sub(_amount);
balances[_account] = balances[_account].sub(_amount);
@ -193,7 +193,7 @@ contract StandardToken is ERC20 {
* @param _amount The amount that will be burnt.
*/
function _burnFrom(address _account, uint256 _amount) internal {
require(allowed[_account][msg.sender] > _amount);
require(_amount <= allowed[_account][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.