From: Tom Hughes Date: Thu, 28 Oct 2004 07:56:44 +0000 (+0000) Subject: When augmenting the argument vector from the VALGRIND_OPTS environment X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08e9ab9e62ccc162dfc2c4278e59ea0401543af4;p=thirdparty%2Fvalgrind.git When augmenting the argument vector from the VALGRIND_OPTS environment 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 --- diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c index 80edcffa1a..c723bb6016 100644 --- a/coregrind/vg_main.c +++ b/coregrind/vg_main.c @@ -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;