Make sure to copy the null terminator at the end of the argv list. Some
authorChris Lattner <sabre@nondot.org>
Tue, 10 Feb 2004 19:14:44 +0000 (19:14 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 10 Feb 2004 19:14:44 +0000 (19:14 +0000)
programs use it instead of argc.

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

runtime/libprofile/CommonProfiling.c

index 7e9e12e42325521bba47b3c4e37b942d2f24d3ff..aeb9c606e4e34eda3a625e3b8066ac230d310077 100644 (file)
@@ -41,7 +41,7 @@ int save_arguments(int argc, const char **argv) {
      * what to do with it.
      */
     const char *Arg = argv[1];
-    memmove(&argv[1], &argv[2], (argc-2)*sizeof(char*));
+    memmove(&argv[1], &argv[2], (argc-1)*sizeof(char*));
     --argc;
 
     if (!strcmp(Arg, "-llvmprof-output")) {
@@ -49,7 +49,7 @@ int save_arguments(int argc, const char **argv) {
         puts("-llvmprof-output requires a filename argument!");
       else {
         OutputFilename = strdup(argv[1]);
-        memmove(&argv[1], &argv[2], (argc-2)*sizeof(char*));
+        memmove(&argv[1], &argv[2], (argc-1)*sizeof(char*));
         --argc;
       }
     } else {