The {“extends”: “solhint:recommended”} property in a configuration file enables this rule.
Possible reentrancy vulnerabilities. Avoid state changes after transfer.
This rule accepts a string option of rule severity. Must be one of “error”, “warn”, “off”. Default to warn.
{
"rules": {
"reentrancy": "warn"
}
}
pragma solidity 0.4.4;
contract A {
mapping(address => uint) private shares;
function b() external {
uint amount = shares[msg.sender];
shares[msg.sender] = 0;
msg.sender.transfer(amount);
}
}
pragma solidity 0.4.4;
contract A {
mapping(address => uint) private shares;
function b() external {
uint amount = shares[msg.sender];
user.test(amount);
shares[msg.sender] = 0;
}
}
pragma solidity 0.4.4;
contract A {
function b() public {
uint[] shares;
uint amount = shares[msg.sender];
msg.sender.transfer(amount);
shares[msg.sender] = 0;
}
}
pragma solidity 0.4.4;
contract A {
mapping(address => uint) private shares;
function b() external {
uint amount = shares[msg.sender];
bool a = msg.sender.send(amount);
if (a) { shares[msg.sender] = 0; }
}
}
pragma solidity 0.4.4;
contract A {
mapping(address => uint) private shares;
function b() external {
uint amount = shares[msg.sender];
msg.sender.transfer(amount);
shares[msg.sender] = 0;
}
}
This rule was introduced in Solhint 1.1.6