]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Don't print the client's argv[i] if it's null, and related changes.
authorNicholas Nethercote <njn@valgrind.org>
Tue, 13 Sep 2005 00:46:27 +0000 (00:46 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Tue, 13 Sep 2005 00:46:27 +0000 (00:46 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4629

cachegrind/cg_main.c
include/pub_tool_libcproc.h
massif/ms_main.c

index 9897056278c081122001024df1434adbc22e781b..084bd9d7208620ea4579e0db6ed2c454111f84b2 100644 (file)
@@ -896,10 +896,10 @@ static void fprint_CC_table_and_calc_totals(void)
    VG_(strcpy)(buf, "cmd:");
    VG_(write)(fd, (void*)buf, VG_(strlen)(buf));
    for (i = 0; i < VG_(client_argc); i++) {
-       if (VG_(client_argv)[i] == NULL)
-          continue;
-       VG_(write)(fd, " ", 1);
-       VG_(write)(fd, VG_(client_argv)[i], VG_(strlen)(VG_(client_argv)[i]));
+       if (VG_(client_argv)[i]) {
+          VG_(write)(fd, " ", 1);
+          VG_(write)(fd, VG_(client_argv)[i], VG_(strlen)(VG_(client_argv)[i]));
+       }
    }
    // "events:" line
    VG_(sprintf)(buf, "\nevents: Ir I1mr I2mr Dr D1mr D2mr Dw D1mw D2mw\n");
index e8588f52561d86f4cc1a2da85dd93e367e196515..b4e008010a91a4d407b44f1ee5e7c2b28ce538e0 100644 (file)
@@ -35,7 +35,9 @@
    Command-line and environment stuff
    ------------------------------------------------------------------ */
 
-/* Client args and environment (which can be inspected with VG_(getenv)(). */
+/* Client args and environment.  Note that VG_(client_argv)[] can be written
+   to by the client, so you should check each entry is non-NULL before
+   printing.  VG_(client_envp) can be inspected with VG_(getenv)(). */
 extern Int    VG_(client_argc);
 extern Char** VG_(client_argv);
 extern Char** VG_(client_envp);
index d4d2b6b3b9d304100023d963a94a30e2fc533aaf..9a2ae7e0b4be5887a353629a9692c1e84b261a62 100644 (file)
@@ -1341,8 +1341,10 @@ static void write_hp_file(void)
 
    // File header, including command line
    SPRINTF(buf, "JOB         \"");
-   for (i = 0; i < VG_(client_argc); i++)
-      SPRINTF(buf, "%s ", VG_(client_argv)[i]);
+   for (i = 0; i < VG_(client_argc); i++) {
+      if (VG_(client_argv)[i])
+         SPRINTF(buf, "%s ", VG_(client_argv)[i]);
+   }
    SPRINTF(buf, /*" (%d ms/sample)\"\n"*/ "\"\n"
                 "DATE        \"\"\n"
                 "SAMPLE_UNIT \"ms\"\n"
@@ -1664,8 +1666,10 @@ write_text_file(ULong total_ST, ULong heap_ST)
 
    // Command line
    SPRINTF(buf, "Command: ");
-   for (i = 0; i < VG_(client_argc); i++)
-      SPRINTF(buf, "%s ", VG_(client_argv)[i]);
+   for (i = 0; i < VG_(client_argc); i++) {
+      if (VG_(client_argv)[i])
+         SPRINTF(buf, "%s ", VG_(client_argv)[i]);
+   }
    SPRINTF(buf, "\n%s\n", maybe_p);
 
    if (clo_heap)