Skip to content

Commit b509a2c

Browse files
authored
Fix false positives on constructor (#1729)
1 parent c309a2b commit b509a2c

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

mythril/analysis/module/modules/external_calls.py

+3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ def _analyze_state(self, state: GlobalState):
7171
:param state:
7272
:return:
7373
"""
74+
if state.environment.active_function_name == "constructor":
75+
return []
76+
7477
gas = state.mstate.stack[-1]
7578
to = state.mstate.stack[-2]
7679

mythril/analysis/module/modules/state_change_external_calls.py

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def __copy__(self):
4242
def get_issue(
4343
self, global_state: GlobalState, detector: DetectionModule
4444
) -> Optional[PotentialIssue]:
45+
4546
if not self.state_change_states:
4647
return None
4748
constraints = Constraints()
@@ -146,6 +147,9 @@ def _add_external_call(global_state: GlobalState) -> None:
146147

147148
def _analyze_state(self, global_state: GlobalState) -> List[PotentialIssue]:
148149

150+
if global_state.environment.active_function_name == "constructor":
151+
return []
152+
149153
annotations = cast(
150154
List[StateChangeCallsAnnotation],
151155
list(global_state.get_annotations(StateChangeCallsAnnotation)),

mythril/analysis/report.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,7 @@ def add_code_info(self, contract):
146146
"""
147147
if self.address and isinstance(contract, SolidityContract):
148148
is_constructor = False
149-
if (
150-
contract.creation_code
151-
in self.transaction_sequence["steps"][-1]["input"]
152-
and self.function == "constructor"
153-
):
149+
if self.function == "constructor":
154150
is_constructor = True
155151

156152
if self.source_location:

0 commit comments

Comments
 (0)