Fix the code lines mapping

pull/381/head
Nikhil Parasaram 6 years ago
parent b7f86f13f8
commit 29f89864d0
  1. 2
      mythril/ether/soliditycontract.py
  2. 2
      mythril/support/truffle.py

@ -109,7 +109,7 @@ class SolidityContract(ETHContract):
offset = self.mappings[index].offset offset = self.mappings[index].offset
length = self.mappings[index].length 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 lineno = self.mappings[index].lineno
return SourceCodeInfo(filename, lineno, code) return SourceCodeInfo(filename, lineno, code)

@ -90,7 +90,7 @@ def analyze_truffle_project(args):
length = mappings[index].length length = mappings[index].length
issue.filename = filename 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 issue.lineno = mappings[index].lineno
except IndexError: except IndexError:
logging.debug("No code mapping at index %d", index) logging.debug("No code mapping at index %d", index)

Loading…
Cancel
Save