]> granicus.if.org Git - clang/commitdiff
PR4991: Properly remove trailing newline from __TIMESTAMP__.
authorBenjamin Kramer <benny.kra@googlemail.com>
Wed, 16 Sep 2009 13:10:04 +0000 (13:10 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Wed, 16 Sep 2009 13:10:04 +0000 (13:10 +0000)
Replace strcpy with memcpy while at it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82043 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/PPMacroExpansion.cpp

index 47056fc380db4da709e2b7bfb569f52d02b08ae9..7ddf215020d019de0ce20170eb9230555c744c5c 100644 (file)
@@ -622,9 +622,9 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
       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__) {