In Lexer::getCharAndSizeSlow[NoWarn] make sure we don't go over the end of the buffer
when the end of the buffer is immediately after an escaped newline.
Fixes http://llvm.org/PR10153.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147091 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp
index 25e320d..acb5b8a 100644
--- a/lib/Lex/Lexer.cpp
+++ b/lib/Lex/Lexer.cpp
@@ -1171,6 +1171,10 @@
// Found backslash<whitespace><newline>. Parse the char after it.
Size += EscapedNewLineSize;
Ptr += EscapedNewLineSize;
+
+ if (Ptr[0] == '\0')
+ return '\\';
+
// Use slow version to accumulate a correct size field.
return getCharAndSizeSlow(Ptr, Size, Tok);
}
@@ -1222,6 +1226,9 @@
Size += EscapedNewLineSize;
Ptr += EscapedNewLineSize;
+ if (Ptr[0] == '\0')
+ return '\\';
+
// Use slow version to accumulate a correct size field.
return getCharAndSizeSlowNoWarn(Ptr, Size, Features);
}