Skip to content

Commit d7831d2

Browse files
author
Max Schaefer
committed
JavaScript: Short-circuit bad-header check on empty files.
1 parent e8510fe commit d7831d2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ private boolean hasBadFileHeader(File f, String lcExt, ExtractorConfig config) {
156156
byte[] bytes = new byte[fileHeaderSize];
157157
int length = fis.read(bytes);
158158

159+
if (length == -1)
160+
return false;
161+
159162
// Avoid invalid or unprintable UTF-8 files.
160163
if (config.getDefaultEncoding().equals("UTF-8") && hasUnprintableUtf8(bytes, length)) {
161164
return true;

0 commit comments

Comments
 (0)