r260219 - Fix possible OOB access found by buildbot
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 9 03:01:58 PST 2016
Author: abataev
Date: Tue Feb 9 05:01:58 2016
New Revision: 260219
URL: http://llvm.org/viewvc/llvm-project?rev=260219&view=rev
Log:
Fix possible OOB access found by buildbot
Modified:
cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=260219&r1=260218&r2=260219&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Tue Feb 9 05:01:58 2016
@@ -573,19 +573,20 @@ struct UnknownPragmaHandler : public Pra
Token &PragmaTok) override {
// Figure out what line we went to and insert the appropriate number of
// newline characters.
+ Callbacks->startNewLineIfNeeded();
+ Callbacks->MoveToLine(PragmaTok.getLocation());
+ Callbacks->OS.write(Prefix, strlen(Prefix));
+
if (ShouldExpandTokens) {
// The first token does not have expanded macros. Expand them, if
// required.
- Token Toks[] = {PragmaTok};
- PP.EnterTokenStream(Toks, llvm::array_lengthof(Toks),
+ Token *Toks = new Token[1];
+ Toks[0] = PragmaTok;
+ PP.EnterTokenStream(Toks, /*NumToks=*/1,
/*DisableMacroExpansion=*/false,
- /*OwnsTokens=*/false);
+ /*OwnsTokens=*/true);
PP.Lex(PragmaTok);
}
- Callbacks->startNewLineIfNeeded();
- Callbacks->MoveToLine(PragmaTok.getLocation());
- Callbacks->OS.write(Prefix, strlen(Prefix));
-
Token PrevToken;
Token PrevPrevToken;
PrevToken.startToken();
More information about the cfe-commits
mailing list