Skip to content

Commit 1a70297

Browse files
committed
JS: fix NPE
1 parent 3481652 commit 1a70297

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,8 @@ private void doExtract(FileExtractor extractor, Path file, ExtractorState state)
12341234
ParseResultInfo loc = extractor.extract(f, state);
12351235
if (!extractor.getConfig().isExterns() && (loc == null || loc.getLinesOfCode() != 0)) seenCode = true;
12361236
if (!extractor.getConfig().isExterns()) seenFiles = true;
1237-
for (ParseError err : loc.getParseErrors()) {
1237+
List<ParseError> errors = loc == null ? Collections.emptyList() : loc.getParseErrors();
1238+
for (ParseError err : errors) {
12381239
String msg = "A parse error occurred: " + StringUtil.escapeMarkdown(err.getMessage())
12391240
+ ". Check the syntax of the file. If the file is invalid, correct the error or [exclude](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning) the file from analysis.";
12401241
// file, relative to the source root

0 commit comments

Comments
 (0)