Static Analyzer for Solidity
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
slither/tests/detectors/calls-loop/0.6.11/multiple_calls_in_loop.sol

49 lines
1.2 KiB

contract CallInLoopBase {
address[] destinations_base;
constructor(address[] memory newDestinations) public {
destinations_base = newDestinations;
}
function bad_base() external{
for (uint i=0; i < destinations_base.length; i++){
address(uint160(destinations_base[i])).transfer(i);
}
}
}
contract CallInLoop is CallInLoopBase{
address[] destinations;
constructor(address[] memory newDestinations) CallInLoopBase(newDestinations) public{
destinations = newDestinations;
}
function bad() external{
for (uint i=0; i < destinations.length; i++){
address(uint160(destinations[i])).transfer(i);
}
}
function bad2() external {
for (uint i=0; i < destinations.length; i++){
for (uint j=0; j < destinations.length; j++){
// Do something
}
address(uint160(destinations[i])).transfer(i);
}
}
function bad3() external {
for (uint i=0; i < destinations.length; i++){
bad3_internal(destinations[i], i);
}
}
function bad3_internal(address a, uint i) internal {
address(uint160(a)).transfer(i);
}
}