Skip to content

Instantly share code, notes, and snippets.

@devonwesley
Created October 13, 2017 23:57
Show Gist options
  • Save devonwesley/38eeb4e06b31896af950e54e28a56d0b to your computer and use it in GitHub Desktop.
Save devonwesley/38eeb4e06b31896af950e54e28a56d0b to your computer and use it in GitHub Desktop.
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