Skip to content

Commit 3641fd2

Browse files
committed
[Heavy] Ensure null terminator for clang lexer
1 parent f3969c6 commit 3641fd2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

clang/lib/Parse/ParseDeclHeavy.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ class LexerWriter {
105105
if (Chars.empty()) return;
106106
// Copy to LexerSpellings to ensure null terminator.
107107
Chars = Chars.copy(LexerSpellings);
108+
char* NullTerm = LexerSpellings.template Allocate<char>(1);
109+
*NullTerm = 0;
108110
// Lex Tokens for the TokenBuffer.
109111
clang::Lexer Lexer(clang::SourceLocation(), Parser.getLangOpts(),
110112
Chars.data(), Chars.data(), &(*(Chars.end())));

0 commit comments

Comments
 (0)