Skip to content

Commit a7c0113

Browse files
authored
Merge pull request #8741 from geoffw0/autogen
C++: Fix issue with extremely long comments in AutogeneratedFile.qll
2 parents b433f08 + 0aa1945 commit a7c0113

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

cpp/ql/lib/semmle/code/cpp/AutogeneratedFile.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ private int fileHeaderLimit(File f) {
8484
fc = fileFirstComment(f) and
8585
result =
8686
min(int line |
87+
// code ending the initial comments
8788
exists(DeclarationEntry de, Location l |
8889
l = de.getLocation() and
8990
l.getFile() = f and
@@ -105,7 +106,13 @@ private int fileHeaderLimit(File f) {
105106
line > fc
106107
)
107108
or
109+
// end of the file
108110
line = f.getMetrics().getNumberOfLines()
111+
or
112+
// rarely, we've seen extremely long sequences of initial comments
113+
// (and/or limitations in the above constraints) cause an overflow of
114+
// the maximum string length. So don't look past 1000 lines regardless.
115+
line = 1000
109116
)
110117
)
111118
}

0 commit comments

Comments
 (0)