Skip to content

Commit

Permalink
Avoid potential re-entrancy attacks in the donate() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
kwight committed Nov 28, 2021
1 parent 3c9e1f3 commit 7318064
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions contracts/Fundraisers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,15 @@ contract Fundraisers is Ownable {
"program is not active"
);
Program memory receivingProgram = programs[programId];
(bool sent, ) = receivingProgram.charity.call{value: msg.value}("");
require(sent, "ether not sent to charity");
donations.push(
Donation({
doner: msg.sender,
programId: programId,
amount: msg.value
})
);
(bool sent, ) = receivingProgram.charity.call{value: msg.value}("");
require(sent, "ether not sent to charity");
emit DonationReceived(
msg.value,
receivingProgram.charity,
Expand Down

0 comments on commit 7318064

Please sign in to comment.