From cf7d0c73ed5c7736f59ac6243e1d98c3fabd42f5 Mon Sep 17 00:00:00 2001 From: Josselin Date: Tue, 10 Sep 2019 13:55:03 +0200 Subject: [PATCH] Fix incorrect for(;;) parsing if break is present --- 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 9ec13cef8..15b222989 100644 --- a/slither/solc_parsing/declarations/function.py +++ b/slither/solc_parsing/declarations/function.py @@ -824,7 +824,12 @@ class FunctionSolc(Function): end_node = self._find_end_loop(node, [], 0) if not end_node: - raise ParsingError('Break in no-loop context {}'.format(node)) + # If there is not end condition on the loop + # The exploration will reach a STARTLOOP before reaching the endloop + # We start with -1 as counter to catch this corner case + end_node = self._find_end_loop(node, [], -1) + if not end_node: + raise ParsingError('Break in no-loop context {}'.format(node.function)) for son in node.sons: son.remove_father(node)