diff --git a/ql/src/codeql/files/FileSystem.qll b/ql/src/codeql/files/FileSystem.qll index e14b3fb9311..25da10a0d92 100644 --- a/ql/src/codeql/files/FileSystem.qll +++ b/ql/src/codeql/files/FileSystem.qll @@ -183,7 +183,11 @@ class File extends Container, @file { } /** Gets the number of lines in this file. */ - int getNumberOfLines() { result = max(this.getAToken().getLocation().getEndLine()) } + int getNumberOfLines() { + if exists(this.getAToken()) + then result = max(this.getAToken().getLocation().getEndLine()) + else result = 0 + } /** Gets the number of lines of code in this file. */ int getNumberOfLinesOfCode() { result = count(int line | this.line(line, false)) }