BUGFIX: process_cmd_line_options mangles options with the syntax
--TOOLNAME:option=foo.  If you use --trace-children=yes, the child
Valgrinds are passed the mangled options and fail as a result.

This patch makes sure that process_cmd_line_options makes a copy of
the option before mangling it.




git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3318 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c
index 5338118..1793faf 100644
--- a/coregrind/vg_main.c
+++ b/coregrind/vg_main.c
@@ -1645,7 +1645,7 @@
             // prefix matches, convert "--toolname:foo" to "--foo"
             if (0)
                VG_(printf)("tool-specific arg: %s\n", arg);
-            arg += toolname_len + 1;
+            arg = strdup(arg + toolname_len + 1);
             arg[0] = '-';
             arg[1] = '-';
 
@@ -1657,14 +1657,14 @@
       
       /* Ignore these options - they've already been handled */
       if (VG_CLO_STREQN(7, arg, "--tool="))
-	 continue;
+	 goto skip_arg;
       if (VG_CLO_STREQN(7, arg, "--exec="))
-	 continue;
+	 goto skip_arg;
       if (VG_CLO_STREQN(20, arg, "--command-line-only="))
-	 continue;
+	 goto skip_arg;
 
       if (     VG_CLO_STREQ(arg, "--"))
-	 continue;
+	 goto skip_arg;
 
       else if (VG_CLO_STREQ(arg, "-v") ||
                VG_CLO_STREQ(arg, "--verbose"))
@@ -1819,6 +1819,9 @@
              || ! TL_(process_cmd_line_option)(arg) ) {
          VG_(bad_option)(arg);
       }
+    skip_arg:
+      if (arg != vg_argv[i])
+         free(arg);
    }
 
    /* Make VEX control parameters sane */