diff --git a/examples/ex1_idaapi.py b/examples/ex1_idaapi.py index 8902ab8..4729554 100644 --- a/examples/ex1_idaapi.py +++ b/examples/ex1_idaapi.py @@ -15,7 +15,14 @@ def main(): seg = getseg(ea) # Loop from segment start to end - func = get_next_func(seg.startEA) + func_ea = seg.startEA + + # Get a function at the start of the segment (if any) + func = get_func(func_ea) + if func is None: + # No function there, try to get the next one + func = get_next_func(func_ea) + seg_end = seg.endEA while func is not None and func.startEA < seg_end: funcea = func.startEA