PR4991: Properly remove trailing newline from __TIMESTAMP__.
Replace strcpy with memcpy while at it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82043 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp
index 47056fc..7ddf215 100644
--- a/lib/Lex/PPMacroExpansion.cpp
+++ b/lib/Lex/PPMacroExpansion.cpp
@@ -622,9 +622,9 @@
Result = "??? ??? ?? ??:??:?? ????\n";
}
TmpBuffer[0] = '"';
- strcpy(TmpBuffer+1, Result);
- unsigned Len = strlen(TmpBuffer);
- TmpBuffer[Len] = '"'; // Replace the newline with a quote.
+ unsigned Len = strlen(Result);
+ memcpy(TmpBuffer+1, Result, Len-1); // Copy string without the newline.
+ TmpBuffer[Len] = '"';
Tok.setKind(tok::string_literal);
CreateString(TmpBuffer, Len+1, Tok, Tok.getLocation());
} else if (II == Ident__COUNTER__) {