[go: nahoru, domu]

Skip to content

Commit

Permalink
fix a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaofeng committed Jul 27, 2020
1 parent 542d68c commit e8fb845
Show file tree
Hide file tree
Showing 9 changed files with 1,594 additions and 2,750 deletions.
8 changes: 4 additions & 4 deletions src/Configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
{"literal2Exp": true},
{"splitBoolVariable": true},
{"arrayMergeCollapse": true},
{"scalar2Vector": true},
{"replaceVarName": true},
{"changeFormat": true},
{"deleteComment": true}
{"scalar2Vector": false},
{"replaceVarName": false},
{"changeFormat": false},
{"deleteComment": false}
]
}
29 changes: 29 additions & 0 deletions src/IntegerSignednessError.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
pragma solidity 0.6.2;

//based on Osiris

/*
If A is less than 0, the value of B will be large when A is converted to an
unsigned integer B of the same width. Consider withdrawOnce function in this
example, enter a negative value will lead to the contract when the balance
of a roll out more than 1 ether.
*/

contract signednessError{
mapping(address => bool) public transferred;
address public owner;

constructor() public payable{
owner = msg.sender;
require(msg.value > 0 && msg.value % 1 ether == 0);
}

function withdrawOnce (int amount) public {
if ( amount > 1 ether || transferred [msg.sender]) {
revert() ;
}
//In Solidity, casting a negative integer to an unsigned integer results in an error and does not throw an exception. Avoid such conversions.
msg.sender.transfer(uint(amount));
transferred [msg.sender] = true ;
}
}
Loading

0 comments on commit e8fb845

Please sign in to comment.