Created
June 30, 2016 19:35
-
-
Save chejazi/ccfc84342261e61923b05340744145cd 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
contract Inconsistency { | |
struct Value { | |
uint badnum; | |
uint number; | |
} | |
struct Container { | |
uint[] valueIndices; | |
Value[] values; | |
} | |
Container[] containers; | |
uint[] valueIndices; | |
uint INDEX_ZERO = 0; | |
uint public debug; | |
// Called with params: containerIndex=0, valueIndex=0 | |
function levelIII(uint containerIndex, uint valueIndex) private { | |
Container container = containers[containerIndex]; | |
Value value = container.values[valueIndex]; | |
// This sets debug to badnum instead of zero | |
debug = container.valueIndices[value.number]; | |
} | |
// `for` loop and `INDEX_ZERO` are both necessary to trigger | |
function LevelII() private { | |
for (uint i = 0; i < valueIndices.length; i++) { | |
levelIII(INDEX_ZERO, valueIndices[i]); | |
} | |
} | |
function Trigger() public { | |
containers.length++; | |
Container container = containers[0]; | |
uint index = container.values.length; | |
container.values.push(Value({ | |
badnum: 9000, | |
number: index | |
})); | |
container.valueIndices.length++; | |
container.valueIndices[0] = index; | |
valueIndices.length++; | |
valueIndices[0] = index; | |
LevelII(); | |
} | |
// This function and its body are necessary | |
function DoNotCallButDoNotDelete() public { | |
LevelII(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment