Skip to content

Commit

Permalink
Fix crash when variable is initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
smonicas committed May 14, 2023
1 parent 58e01ea commit 408c863
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion slither/detectors/variables/uninitialized_local_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def _detect_uninitialized(
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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}

}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}

}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}

}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}

}
Binary file not shown.

0 comments on commit 408c863

Please sign in to comment.