Created
October 13, 2017 23:57
-
-
Save devonwesley/38eeb4e06b31896af950e54e28a56d0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.8; | |
contract Victim { | |
bool locked; | |
/** | |
@dev Modifier to insure that functions cannot be reentered | |
during execution. Note there is only one global "locked" var, so | |
there is a potential to be locked out of all functions that use | |
the modifier at the same time. | |
*/ | |
modifier noReentrancy() { | |
require(!locked); | |
locked = true; | |
_; | |
locked = false; | |
} | |
function withdraw() noReentrancy { | |
uint transferAmt = 1 ether; | |
if (!msg.sender.call.value(transferAmt)()) throw; | |
} | |
function deposit() payable {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment