From f468cda4c13e52cb9820f56e757b3b9827e93c4c Mon Sep 17 00:00:00 2001 From: Josselin Date: Tue, 12 Feb 2019 05:33:52 -0500 Subject: [PATCH] Change: - node.is_conditional: consider return bool as a conditional node --- slither/core/cfg/node.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/slither/core/cfg/node.py b/slither/core/cfg/node.py index 855871684..d4c70840e 100644 --- a/slither/core/cfg/node.py +++ b/slither/core/cfg/node.py @@ -10,12 +10,13 @@ from slither.core.source_mapping.source_mapping import SourceMapping from slither.core.variables.local_variable import LocalVariable from slither.core.variables.state_variable import StateVariable from slither.core.variables.variable import Variable +from slither.core.solidity_types import ElementaryType from slither.slithir.convert import convert_expression from slither.slithir.operations import (Balance, HighLevelCall, Index, InternalCall, Length, LibraryCall, LowLevelCall, Member, OperationWithLValue, Phi, PhiCallback, - SolidityCall) + SolidityCall, Return) from slither.slithir.variables import (Constant, LocalIRVariable, ReferenceVariable, StateIRVariable, TemporaryVariable, TupleVariable) @@ -424,11 +425,21 @@ class Node(SourceMapping, ChildFunction): def is_conditional(self, include_loop=True): """ Check if the node is a conditional node - A conditional node is either a IF or a require/assert + A conditional node is either a IF or a require/assert or a RETURN bool Returns: bool: True if the node is a conditional node """ - return self.contains_if(include_loop) or self.contains_require_or_assert() + if self.contains_if(include_loop) or self.contains_require_or_assert(): + return True + if self.irs: + last_ir = self.irs[-1] + if last_ir: + if isinstance(last_ir, Return): + for r in last_ir.read: + if r.type == ElementaryType('bool'): + return True + return False + # endregion