mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #1763 from nemofisch/develop
Fix delegation loop in Ballot example contract
This commit is contained in:
commit
b22369d590
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user