Skip to content

Commit

Permalink
core: frontends: c: fix paramter iteration
Browse files Browse the repository at this point in the history
Signed-off-by: David Korczynski <david@adalogics.com>
  • Loading branch information
DavidKorczynski committed Feb 8, 2025
1 parent a475783 commit cecbe58
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/fuzz_introspector/frontends/frontend_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,13 @@ def _traverse_node_instr_count(node):
def get_function_arg_names(self):
"""Gets the same of a function's arguments"""
param_names = []
parameters_node = self.root.child_by_field_name(
'declarator').child_by_field_name('parameters')

tmp_node = self.root.child_by_field_name('declarator')
while (tmp_node.child_by_field_name('declarator') is not None
and tmp_node.child_by_field_name('parameters') is None):
tmp_node = tmp_node.child_by_field_name('declarator')

parameters_node = tmp_node.child_by_field_name('parameters')
if not parameters_node:
return param_names

Expand All @@ -356,9 +361,12 @@ def get_function_arg_types(self):
"""Gets the text of a function's types"""
param_types = []

parameters_node = self.root.child_by_field_name(
'declarator').child_by_field_name('parameters')
tmp_node = self.root.child_by_field_name('declarator')
while (tmp_node.child_by_field_name('declarator') is not None
and tmp_node.child_by_field_name('parameters') is None):
tmp_node = tmp_node.child_by_field_name('declarator')

parameters_node = tmp_node.child_by_field_name('parameters')
if not parameters_node:
return param_types

Expand Down

0 comments on commit cecbe58

Please sign in to comment.