Fix crash when variable is initialized

pull/1911/head
Simone 2 years ago
parent 58e01ea218
commit 408c863bbf
  1. 3
      slither/detectors/variables/uninitialized_local_variables.py
  2. 5
      tests/e2e/detectors/test_data/uninitialized-local/0.4.25/uninitialized_local_variable.sol
  3. BIN
      tests/e2e/detectors/test_data/uninitialized-local/0.4.25/uninitialized_local_variable.sol-0.4.25.zip
  4. 5
      tests/e2e/detectors/test_data/uninitialized-local/0.5.16/uninitialized_local_variable.sol
  5. BIN
      tests/e2e/detectors/test_data/uninitialized-local/0.5.16/uninitialized_local_variable.sol-0.5.16.zip
  6. 5
      tests/e2e/detectors/test_data/uninitialized-local/0.6.11/uninitialized_local_variable.sol
  7. BIN
      tests/e2e/detectors/test_data/uninitialized-local/0.6.11/uninitialized_local_variable.sol-0.6.11.zip
  8. 5
      tests/e2e/detectors/test_data/uninitialized-local/0.7.6/uninitialized_local_variable.sol
  9. BIN
      tests/e2e/detectors/test_data/uninitialized-local/0.7.6/uninitialized_local_variable.sol-0.7.6.zip

@ -70,7 +70,8 @@ Bob calls `transfer`. As a result, all Ether is sent to the address `0x0` and is
and len(node.sons) == 1 # Should always be true for a node that has a STARTLOOP son
and node.sons[0].type == NodeType.STARTLOOP
):
fathers_context.remove(node.variable_declaration)
if node.variable_declaration in fathers_context:
fathers_context.remove(node.variable_declaration)
if self.key in node.context:
fathers_context += node.context[self.key]

@ -10,6 +10,11 @@ contract Uninitialized{
for(uint i; i < 6; i++) {
uint a = i;
}
for(uint j = 0; j < 6; j++) {
uint b = j;
}
}
}

@ -10,6 +10,11 @@ contract Uninitialized{
for(uint i; i < 6; i++) {
uint a = i;
}
for(uint j = 0; j < 6; j++) {
uint b = j;
}
}
}

@ -10,6 +10,11 @@ contract Uninitialized{
for(uint i; i < 6; i++) {
uint a = i;
}
for(uint j = 0; j < 6; j++) {
uint b = j;
}
}
}

@ -10,6 +10,11 @@ contract Uninitialized{
for(uint i; i < 6; i++) {
uint a = i;
}
for(uint j = 0; j < 6; j++) {
uint b = j;
}
}
}

Loading…
Cancel
Save