From 93965debbf6c0b01e0076734ef140dc9898164c6 Mon Sep 17 00:00:00 2001 From: Nikhil Parasaram Date: Thu, 19 Oct 2023 15:44:42 +0100 Subject: [PATCH] Fix edge case w.r.t solc versions (#1812) --- mythril/mythril/mythril_disassembler.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/mythril/mythril/mythril_disassembler.py b/mythril/mythril/mythril_disassembler.py index e1acc644..236327af 100644 --- a/mythril/mythril/mythril_disassembler.py +++ b/mythril/mythril/mythril_disassembler.py @@ -232,6 +232,17 @@ class MythrilDisassembler: return address, contracts def check_run_integer_module(self, source_file): + + with open(source_file, "r") as f: + for line in f: + if "unchecked" in line: + return True + + if self.solc_version is None: + # Runs the version installed in the system (likely 0.8.0+) + # Post 0.8.0 versions automatically add assertions to sanity check arithmetic + return False + # Strip leading 'v' from version if it's there normalized_version = self.solc_version.lstrip("v") @@ -242,11 +253,6 @@ class MythrilDisassembler: ): return True - with open(source_file, "r") as f: - for line in f: - if "unchecked" in line: - return True - return False def load_from_solidity(