diff --git a/mythril/ether/soliditycontract.py b/mythril/ether/soliditycontract.py index 7e544800..f5825d0e 100644 --- a/mythril/ether/soliditycontract.py +++ b/mythril/ether/soliditycontract.py @@ -109,7 +109,7 @@ class SolidityContract(ETHContract): offset = self.mappings[index].offset length = self.mappings[index].length - code = solidity_file.data[offset:offset + length] + code = solidity_file.data.encode('utf-8')[offset:offset + length].decode('utf-8') lineno = self.mappings[index].lineno return SourceCodeInfo(filename, lineno, code) diff --git a/mythril/support/truffle.py b/mythril/support/truffle.py index 140df386..d59879ab 100644 --- a/mythril/support/truffle.py +++ b/mythril/support/truffle.py @@ -90,7 +90,7 @@ def analyze_truffle_project(args): length = mappings[index].length issue.filename = filename - issue.code = source[offset:offset + length] + issue.code = source.encode('utf-8')[offset:offset + length].decode('utf-8') issue.lineno = mappings[index].lineno except IndexError: logging.debug("No code mapping at index %d", index)