diff options
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/Lexer.java | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Lexer.java b/src/main/java/com/google/devtools/build/lib/syntax/Lexer.java index 71a3fd1b41..0ace1f2bcf 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/Lexer.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/Lexer.java @@ -489,6 +489,12 @@ public final class Lexer { } } + // If the current position is beyond the end of the file, need to move it backwards + // Possible if the file ends with `r"\` (unterminated raw string literal with a backslash) + if (pos > buffer.length) { + pos = buffer.length; + } + error("unterminated string literal at eof", oldPos, pos); return new Token(TokenKind.STRING, oldPos, pos, bufferSlice(oldPos + 1, pos)); |