Skip to content

Use 'block' instead of undefined 'instr' in get_block_lines method #8084

@B1aNB1aN

Description

@B1aNB1aN

Bug Report

File: python/languagerepresentation.py
Line: 621 (get_block_lines method of LanguageRepresentationFunction)

Description

There is a variable usage bug in the get_block_lines method of the LanguageRepresentationFunction class.
At line 621, the code attempts to reference instr.function, but the variable instr is not defined within the scope of this method.
Given the method signature and context, it should use block instead of instr to retrieve the function instance.

Problematic Code (around line 621)

for i in range(0, count.value):
    addr = lines[i].addr
    if lines[i].instrIndex != 0xffffffffffffffff:
        il_instr = instr.function[lines[i].instrIndex]  # <-- 'instr' is not defined here
    else:
        il_instr = None
    ...

Expected Code

The correct reference should be block.function instead of instr.function, as shown below:

for i in range(0, count.value):
    addr = lines[i].addr
    if lines[i].instrIndex != 0xffffffffffffffff:
        il_instr = block.function[lines[i].instrIndex]
    else:
        il_instr = None
    ...

How to Reproduce

  1. Call get_block_lines for any HighLevelILBasicBlock.
  2. Observe a NameError similar to:
NameError: name 'instr' is not defined

Suggested Fix

Replace all instances of instr.function with block.function within the get_block_lines method to ensure the correct variable is referenced.

Additional Context

If possible, I can submit a pull request to address this issue.

Metadata

Metadata

Assignees

Labels

Component: Python APIIssue needs changes to the python APIEffort: TrivialIssues require < 1 day of workImpact: MediumIssue is impactful with a bad, or no, workaround

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions