Fixes bug where prev_mapping was not being set when file_id == 1

pull/281/head
rajeevgopalakrishna 6 years ago
parent 8944eab3be
commit 209d3a31af
  1. 6
      slither/printers/summary/evm.py

@ -95,6 +95,9 @@ class PrinterEVM(AbstractPrinter):
for idx, mapping in enumerate(srcmap_runtime): for idx, mapping in enumerate(srcmap_runtime):
# Parse srcmap_runtime according to its format # Parse srcmap_runtime according to its format
# See https://solidity.readthedocs.io/en/v0.5.9/miscellaneous.html#source-mappings # 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 = mapping.split(':')
mapping_item += prev_mapping[len(mapping_item):] mapping_item += prev_mapping[len(mapping_item):]
@ -104,6 +107,7 @@ class PrinterEVM(AbstractPrinter):
mapping_item[i] = int(prev_mapping[i]) mapping_item[i] = int(prev_mapping[i])
offset, length, file_id, _ = mapping_item offset, length, file_id, _ = mapping_item
prev_mapping = mapping_item
if file_id == '-1': if file_id == '-1':
# Internal compiler-generated code snippets to be ignored # 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 # Note: The order depends on how solc creates the srcmap_runtime
source_to_evm_mapping.setdefault(line_number, []).append(evm_instructions[idx].pc) source_to_evm_mapping.setdefault(line_number, []).append(evm_instructions[idx].pc)
prev_mapping = mapping_item
return(source_to_evm_mapping) return(source_to_evm_mapping)

Loading…
Cancel
Save