clearbluejar / ghidrecomp

Python Command-Line Ghidra Decompiler
GNU General Public License v3.0
86 stars 9 forks source link

Incorrect Default Parameter in get_calling Function #25

Closed Hpasserby closed 4 months ago

Hpasserby commented 4 months ago

The get_calling function sets the default parameter for cgraph as CallGraph(). Using an object as a default argument in a Python function results in the object being initialized only once. This can lead to unexpected results when the function is called multiple times.

A better approach would be to set the default value of cgraph to None and then initialize it within the function if it is not provided.

def get_calling(f: "ghidra.program.model.listing.Function", cgraph: CallGraph = None, depth: int = 0, visited: tuple = None, verbose=False, include_ns=True, start_time=None, max_run_time=None, max_depth=MAX_DEPTH):
    if cgraph is None:
        cgraph = CallGraph()
clearbluejar commented 4 months ago

good issue. just creating a pull request and running tests.