From 209d3a31af5367e770240e0ab17cd34ea5e6b61c Mon Sep 17 00:00:00 2001 From: rajeevgopalakrishna Date: Thu, 13 Jun 2019 13:57:08 +0530 Subject: [PATCH] Fixes bug where prev_mapping was not being set when file_id == 1 --- slither/printers/summary/evm.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/slither/printers/summary/evm.py b/slither/printers/summary/evm.py index d8ca25c0a..5e540474f 100644 --- a/slither/printers/summary/evm.py +++ b/slither/printers/summary/evm.py @@ -30,7 +30,7 @@ class PrinterEVM(AbstractPrinter): """ evm_info = self._extract_evm_info(self.slither) - + for contract in self.slither.contracts_derived: print('Contract {}'.format(contract.name)) @@ -95,7 +95,10 @@ class PrinterEVM(AbstractPrinter): for idx, mapping in enumerate(srcmap_runtime): # Parse srcmap_runtime according to its format # See https://solidity.readthedocs.io/en/v0.5.9/miscellaneous.html#source-mappings - + # In order to compress these source mappings especially for bytecode, the following rules are used: + # If a field is empty, the value of the preceding element is used. + # If a : is missing, all following fields are considered empty. + mapping_item = mapping.split(':') mapping_item += prev_mapping[len(mapping_item):] @@ -104,6 +107,7 @@ class PrinterEVM(AbstractPrinter): mapping_item[i] = int(prev_mapping[i]) offset, length, file_id, _ = mapping_item + prev_mapping = mapping_item if file_id == '-1': # Internal compiler-generated code snippets to be ignored @@ -118,6 +122,4 @@ class PrinterEVM(AbstractPrinter): # Note: The order depends on how solc creates the srcmap_runtime source_to_evm_mapping.setdefault(line_number, []).append(evm_instructions[idx].pc) - prev_mapping = mapping_item - return(source_to_evm_mapping)