From 62002aa14df1794a0dfa2854f3bdeb4ab7c71181 Mon Sep 17 00:00:00 2001 From: Josselin Date: Thu, 25 Oct 2018 07:49:37 +0100 Subject: [PATCH] Fix incorrect loop recovery --- slither/solc_parsing/declarations/function.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/slither/solc_parsing/declarations/function.py b/slither/solc_parsing/declarations/function.py index 407acdd29..44aff75df 100644 --- a/slither/solc_parsing/declarations/function.py +++ b/slither/solc_parsing/declarations/function.py @@ -197,6 +197,11 @@ class FunctionSolc(Function): if len(children) > 2: if children[-2]['name'] == 'ExpressionStatement': node_LoopExpression = self._parse_statement(children[-2], node_statement) + if not hasCondition: + link_nodes(node_LoopExpression, node_endLoop) + + if not hasCondition and not hasLoopExpression: + link_nodes(node, node_endLoop) link_nodes(node_LoopExpression, node_startLoop) @@ -464,7 +469,7 @@ class FunctionSolc(Function): end_node = self._find_end_loop(node, []) if not end_node: - logger.error('Break in no-loop context {}'.format(node.nodeId())) + logger.error('Break in no-loop context {}'.format(node)) exit(-1) for son in node.sons: