Skip to content

Commit

Permalink
Track curly brace level in extract_c_parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
myersg86 committed Apr 30, 2021
1 parent 1ff7406 commit 7defaf1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion flawfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ def extract_c_parameters(text, pos=0):
parameters = [""] # Insert 0th entry, so 1st parameter is parameter[1].
currentstart = i
parenlevel = 1
curlylevel = 0
instring = 0 # 1=in double-quote, 2=in single-quote
incomment = 0
while i < len(text):
Expand Down Expand Up @@ -579,7 +580,11 @@ def extract_c_parameters(text, pos=0):
# print " EXTRACT_C_PARAMETERS: ", text[pos:pos+80]
# print " RESULTS: ", parameters
return parameters
elif c == ';':
elif c == '{':
curlylevel += 1
elif c == '}':
curlylevel -= 1
elif c == ';' and curlylevel < 1:
internal_warn(
"Parsing failed to find end of parameter list; "
"semicolon terminated it in %s" % text[pos:pos + 200])
Expand Down

0 comments on commit 7defaf1

Please sign in to comment.