From 209e2de93be06110bc7133b46f25a773d0a4c427 Mon Sep 17 00:00:00 2001 From: Pavel Rubin Date: Mon, 28 Aug 2017 21:00:29 +0300 Subject: [PATCH] Fix for #400: Check that destination of token transfers is not 0x --- contracts/token/BasicToken.sol | 2 ++ contracts/token/StandardToken.sol | 2 ++ 2 files changed, 4 insertions(+) diff --git a/contracts/token/BasicToken.sol b/contracts/token/BasicToken.sol index ef35a37a8..e584df274 100644 --- a/contracts/token/BasicToken.sol +++ b/contracts/token/BasicToken.sol @@ -20,6 +20,8 @@ contract BasicToken is ERC20Basic { * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) returns (bool) { + require(_to != address(0)); + balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); diff --git a/contracts/token/StandardToken.sol b/contracts/token/StandardToken.sol index 358d6f05e..74b16a65a 100644 --- a/contracts/token/StandardToken.sol +++ b/contracts/token/StandardToken.sol @@ -24,6 +24,8 @@ contract StandardToken is ERC20, BasicToken { * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) returns (bool) { + require(_to != address(0)); + var _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met