aboutsummaryrefslogtreecommitdiffstats
path: root/docs/solidity-by-example.rst
diff options
context:
space:
mode:
authorRemo Fürst <Remo Fürst>2017-03-09 05:45:27 +0800
committerRemo Fürst <Remo Fürst>2017-03-09 05:45:27 +0800
commitb5c17d70580c050c8ed1d4bf5bb8cefbae443bc4 (patch)
tree322fac62562f6b332f50db1f58220d41eb7f00d8 /docs/solidity-by-example.rst
parente364909e063cf95922b9611b3d25fb0a4199e43f (diff)
downloaddexon-solidity-b5c17d70580c050c8ed1d4bf5bb8cefbae443bc4.tar
dexon-solidity-b5c17d70580c050c8ed1d4bf5bb8cefbae443bc4.tar.gz
dexon-solidity-b5c17d70580c050c8ed1d4bf5bb8cefbae443bc4.tar.bz2
dexon-solidity-b5c17d70580c050c8ed1d4bf5bb8cefbae443bc4.tar.lz
dexon-solidity-b5c17d70580c050c8ed1d4bf5bb8cefbae443bc4.tar.xz
dexon-solidity-b5c17d70580c050c8ed1d4bf5bb8cefbae443bc4.tar.zst
dexon-solidity-b5c17d70580c050c8ed1d4bf5bb8cefbae443bc4.zip
Fix delegation loop in Ballot example contract
fixes #1753
Diffstat (limited to 'docs/solidity-by-example.rst')
-rw-r--r--docs/solidity-by-example.rst16
1 files changed, 8 insertions, 8 deletions
diff --git a/docs/solidity-by-example.rst b/docs/solidity-by-example.rst
index 915cfa76..7e08c6b4 100644
--- a/docs/solidity-by-example.rst
+++ b/docs/solidity-by-example.rst
@@ -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,
@@ -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