]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
When augmenting the argument vector from the VALGRIND_OPTS environment
authorTom Hughes <tom@compton.nu>
Mon, 13 Sep 2004 10:20:34 +0000 (10:20 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 13 Sep 2004 10:20:34 +0000 (10:20 +0000)
variable and/or the .valgrindrc files, make sure that enough space is
allocated for all the old arguments, not just those that are arguments
to valgrind itself.

CCMAIL: 88604-done@bugs.kde.org

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2706

coregrind/vg_main.c

index a077d58c0d9d0d3e0a01845bc3de0669f6453916..0bfa60b5346b80772dba047d26526de928f250e3 100644 (file)
@@ -551,8 +551,10 @@ static void augment_command_line(Int* vg_argc_inout, char*** vg_argv_inout)
       /* ' ' separated extra options */
       char **from;
       char **to;
-      int env_arg_count, f1_arg_count, f2_arg_count;
-      
+      int orig_arg_count, env_arg_count, f1_arg_count, f2_arg_count;
+
+      for ( orig_arg_count = 0; vg_argv0[orig_arg_count]; orig_arg_count++ );
+
       env_arg_count = count_args(env_clo);
       f1_arg_count  = count_args(f1_clo);
       f2_arg_count  = count_args(f2_clo);
@@ -563,7 +565,7 @@ static void augment_command_line(Int* vg_argc_inout, char*** vg_argv_inout)
 
       /* +2: +1 for null-termination, +1 for added '--' */
       from     = vg_argv0;
-      vg_argv0 = malloc( (vg_argc0 + env_arg_count + f1_arg_count 
+      vg_argv0 = malloc( (orig_arg_count + env_arg_count + f1_arg_count 
                           + f2_arg_count + 2) * sizeof(char **));
       vg_assert(vg_argv0);
       to      = vg_argv0;