Commit de90f445 by Nicolás Venturo

Merge pull request #1647 from nventuro/safeerc20-bugfix

Fix SafeERC20.safeApprove bug

(cherry picked from commit 3111291b)
parent 8617c4b4
...@@ -24,7 +24,7 @@ contract ERC20FailingMock { ...@@ -24,7 +24,7 @@ contract ERC20FailingMock {
} }
contract ERC20SucceedingMock { contract ERC20SucceedingMock {
uint256 private _allowance; mapping (address => uint256) private _allowances;
function transfer(address, uint256) public returns (bool) { function transfer(address, uint256) public returns (bool) {
return true; return true;
...@@ -39,11 +39,11 @@ contract ERC20SucceedingMock { ...@@ -39,11 +39,11 @@ contract ERC20SucceedingMock {
} }
function setAllowance(uint256 allowance_) public { function setAllowance(uint256 allowance_) public {
_allowance = allowance_; _allowances[msg.sender] = allowance_;
} }
function allowance(address, address) public view returns (uint256) { function allowance(address owner, address) public view returns (uint256) {
return _allowance; return _allowances[owner];
} }
} }
......
...@@ -24,7 +24,7 @@ library SafeERC20 { ...@@ -24,7 +24,7 @@ library SafeERC20 {
// safeApprove should only be called when setting an initial allowance, // safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use // or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require((value == 0) || (token.allowance(msg.sender, spender) == 0)); require((value == 0) || (token.allowance(address(this), spender) == 0));
require(token.approve(spender, value)); require(token.approve(spender, value));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment