Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions 5_fix_CountContribution.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ contract CountContribution{
* @param _amount The amount of the contribution.
*/
function recordContribution(address _user, uint _amount) {
require(contribution[_user] + _amount >= contribution[_user]);
require(totalContributions + _amount >= totalContributions);
Copy link

@n1c01a5 n1c01a5 Apr 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't sure the second check is necessary. If the first test is okay, the input amount is a valid number.
Your overflow check is good idea but I think there is an another issue.

contribution[_user]+=_amount;
totalContributions+=_amount;
}
Expand Down