Skip to content

Commit

Permalink
Merge pull request ethereum#1763 from nemofisch/develop
Browse files Browse the repository at this point in the history
Fix delegation loop in Ballot example contract
  • Loading branch information
chriseth authored Mar 9, 2017
2 parents e364909 + b5c17d7 commit b22369d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions docs/solidity-by-example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ of votes.
if (sender.voted)
throw;

// Self-delegation is not allowed.
if (to == msg.sender)
throw;

// Forward the delegation as long as
// `to` also delegated.
// In general, such loops are very dangerous,
Expand All @@ -114,16 +118,12 @@ of votes.
// In this case, the delegation will not be executed,
// but in other situations, such loops might
// cause a contract to get "stuck" completely.
while (
voters[to].delegate != address(0) &&
voters[to].delegate != msg.sender
) {
while (voters[to].delegate != address(0)) {
to = voters[to].delegate;
}

// We found a loop in the delegation, not allowed.
if (to == msg.sender) {
throw;
// We found a loop in the delegation, not allowed.
if (to == msg.sender)
throw;
}

// Since `sender` is a reference, this
Expand Down

0 comments on commit b22369d

Please sign in to comment.