Skip to content

Commit

Permalink
Merge pull request sushi-labs#11 from Gabriel-GW/reentrant
Browse files Browse the repository at this point in the history
fix re-entrant risk
  • Loading branch information
boringcrypto authored Oct 23, 2020
2 parents ebee2c5 + 6fc393a commit 1e4db47
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions contracts/MasterChef.sol
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,11 @@ contract MasterChef is Ownable {
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
uint256 amount = user.amount;
user.amount = 0;
user.rewardDebt = 0;
pool.lpToken.safeTransfer(address(msg.sender), amount);
emit EmergencyWithdraw(msg.sender, _pid, amount);
}

// Safe sushi transfer function, just in case if rounding error causes pool to not have enough SUSHIs.
Expand Down

0 comments on commit 1e4db47

Please sign in to comment.