Fix possible OOB access found by buildbot

llvm-svn: 260219
diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
index c57a736..eee9da8 100644
--- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -573,19 +573,20 @@
                     Token &PragmaTok) override {
     // Figure out what line we went to and insert the appropriate number of
     // newline characters.
-    if (ShouldExpandTokens) {
-      // The first token does not have expanded macros. Expand them, if
-      // required.
-      Token Toks[] = {PragmaTok};
-      PP.EnterTokenStream(Toks, llvm::array_lengthof(Toks),
-                          /*DisableMacroExpansion=*/false,
-                          /*OwnsTokens=*/false);
-      PP.Lex(PragmaTok);
-    }
     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 = new Token[1];
+      Toks[0] = PragmaTok;
+      PP.EnterTokenStream(Toks, /*NumToks=*/1,
+                          /*DisableMacroExpansion=*/false,
+                          /*OwnsTokens=*/true);
+      PP.Lex(PragmaTok);
+    }
     Token PrevToken;
     Token PrevPrevToken;
     PrevToken.startToken();