Fix an issue where legacy-ast would fail to detect missing loop components, causing the iterator to be parsed as the initializer, and the loop block to be parsed as the iterator (causing failure).

pull/169/head
David Pokora 6 years ago
parent f8897c3f8f
commit 43fa54dde3
No known key found for this signature in database
GPG Key ID: 3CED48D1BB21BDD7
  1. 12
      slither/solc_parsing/declarations/function.py

@ -257,15 +257,27 @@ class FunctionSolc(Function):
# if the loop has a init value /condition or expression
# There is no way to determine that for(a;;) and for(;a;) are different with old solc
if 'attributes' in statement:
attributes = statement['attributes']
if 'initializationExpression' in statement:
if not statement['initializationExpression']:
hasInitExession = False
elif 'initializationExpression' in attributes:
if not attributes['initializationExpression']:
hasInitExession = False
if 'condition' in statement:
if not statement['condition']:
hasCondition = False
elif 'condition' in attributes:
if not attributes['condition']:
hasCondition = False
if 'loopExpression' in statement:
if not statement['loopExpression']:
hasLoopExpression = False
elif 'loopExpression' in attributes:
if not attributes['loopExpression']:
hasLoopExpression = False
node_startLoop = self._new_node(NodeType.STARTLOOP, statement['src'])

Loading…
Cancel
Save