[m-rev.] diff: fix allocation for MERCURY_OPTIONS_progname

Peter Wang novalazy at gmail.com
Tue May 3 14:14:28 AEST 2011


Branches: main, 11.01

runtime/mercury_wrapper.c:
	Fix allocation when building the MERCURY_OPTIONS_progname
	string, which was short by one byte.

diff --git a/runtime/mercury_wrapper.c b/runtime/mercury_wrapper.c
index 3be930c..1558f57 100644
--- a/runtime/mercury_wrapper.c
+++ b/runtime/mercury_wrapper.c
@@ -1120,7 +1120,7 @@ MR_process_environment_options(void)
 
     /* Build the program-specific option's name: MERCURY_OPTIONS_progname. */
     mercury_options_len = strlen(MERCURY_OPTIONS);
-    prog_env_option_name_len = mercury_options_len + 1 + strlen(progname);
+    prog_env_option_name_len = mercury_options_len + 1 + strlen(progname) + 1;
     prog_env_option_name = MR_GC_NEW_ARRAY(char, prog_env_option_name_len);
     strcpy(prog_env_option_name, MERCURY_OPTIONS);
     prog_env_option_name[mercury_options_len] = '_';

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list