Skip to content

Fix transfers #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 21, 2018
Merged

Fix transfers #4

merged 2 commits into from
Sep 21, 2018

Conversation

pm-coelho
Copy link
Contributor

I was trying out the vulnerabilities shown in the article and found that on some transfers the balance was updated before the transfer was made:

balances[msg.sender] = 0;
msg.sender.transfer(balances[msg.sender]);

I think this solution might be better:

uint transferValue = balances[msg.sender];
balances[msg.sender] = 0;
msg.sender.transfer(transferValue);

Thank you so much for this article, I'm learning a lot from it.

@AgeManning
Copy link
Member

Hey, thanks for catching these. I originally wrote them late at night, so I'm glad someone has corrected my mistakes. I caught one of these errors, recently but I'm glad you've found the rest.

I'm glad this article is helpful, that was its intention.

Thanks again for the PR :)

@AgeManning AgeManning merged commit b18eb32 into sigp:master Sep 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants