下面代码是否有重入攻击的风险,如果没有是否有其他风险

// Withdraw without caring about rewards. EMERGENCY ONLY. 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); user.amount = 0; user.rewardDebt = 0; }

先 safeTransfer 再置0 ,是否有重入攻击的风险, 如果token 没有 safeTransfer 函数 是否能调用成功,谢谢

请先 登录 后评论

1 个回答

Tiny熊
  擅长:智能合约,以太坊
请先 登录 后评论
  • 1 关注
  • 0 收藏,2784 浏览
  • Junior 提出于 2021-05-29 11:58