]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
When augmenting the argument vector from the VALGRIND_OPTS environment
authorTom Hughes <tom@compton.nu>
Thu, 28 Oct 2004 07:56:44 +0000 (07:56 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 28 Oct 2004 07:56:44 +0000 (07:56 +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.

MERGED FROM HEAD

git-svn-id: svn://svn.valgrind.org/valgrind/branches/VALGRIND_2_2_0_BRANCH@2861

coregrind/vg_main.c

index 80edcffa1a17f06df37a56faba0f562c0db7bedb..c723bb60167736d27f2990df5e24fa11bb300879 100644 (file)
@@ -590,7 +590,9 @@ 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);
@@ -602,7 +604,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;