From 29f89864d0061b13336c8af7a880b004e67deade Mon Sep 17 00:00:00 2001 From: Nikhil Parasaram Date: Thu, 26 Jul 2018 17:07:14 +0530 Subject: [PATCH] Fix the code lines mapping --- mythril/ether/soliditycontract.py | 2 +- mythril/support/truffle.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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)