diff --git a/mythril/ether/soliditycontract.py b/mythril/ether/soliditycontract.py index 8577d73c..7e544800 100644 --- a/mythril/ether/soliditycontract.py +++ b/mythril/ether/soliditycontract.py @@ -3,6 +3,7 @@ from mythril.ether.ethcontract import ETHContract from mythril.ether.util import * from mythril.exceptions import NoContractFoundError + class SourceMapping: def __init__(self, solidity_file_idx, offset, length, lineno): @@ -91,8 +92,7 @@ class SolidityContract(ETHContract): if len(mapping) > 2 and len(mapping[2]) > 0: idx = int(mapping[2]) - - lineno = self.solidity_files[idx].data[0:offset].count('\n') + 1 + lineno = self.solidity_files[idx].data.encode('utf-8')[0:offset].count('\n'.encode('utf-8')) + 1 self.mappings.append(SourceMapping(idx, offset, length, lineno)) diff --git a/mythril/support/truffle.py b/mythril/support/truffle.py index f623ba8f..140df386 100644 --- a/mythril/support/truffle.py +++ b/mythril/support/truffle.py @@ -76,7 +76,7 @@ def analyze_truffle_project(args): if len(mapping) > 2 and len(mapping[2]) > 0: idx = int(mapping[2]) - lineno = source[0:offset].count('\n') + 1 + lineno = source.encode('utf-8')[0:offset].count('\n'.encode('utf-8')) + 1 mappings.append(SourceMapping(idx, offset, length, lineno))