diff options
author | Robert Bowdidge <bowdidge@apple.com> | 2004-10-15 19:26:15 +0000 |
---|---|---|
committer | Robert Bowdidge <bowdidge@apple.com> | 2004-10-15 19:26:15 +0000 |
commit | 4138801f0ee9183d462593bc3db8647531846f64 (patch) | |
tree | e6c0ba2d13fa5605457692664a1e1103b8f0f5dd /gcc/config/darwin-driver.c | |
parent | 587bf1e24166a5d75cd28ff91cc431546bb4c846 (diff) |
Radar 3838397: Didn't allocate enough space for strings in darwin-driver.c.
Approved by Zem.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/apple-ppc-branch@89114 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/darwin-driver.c')
-rw-r--r-- | gcc/config/darwin-driver.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gcc/config/darwin-driver.c b/gcc/config/darwin-driver.c index de648c8b6a9..a1e6d3e3f75 100644 --- a/gcc/config/darwin-driver.c +++ b/gcc/config/darwin-driver.c @@ -785,7 +785,7 @@ void read_args (int argc, char **argv) arg_array = (char**) malloc(sizeof(char*)*arg_array_size); for (i=0;i<argc;i++) { - arg_array[i] = malloc (strlen (argv[i])); + arg_array[i] = malloc (strlen (argv[i])+1); strcpy (arg_array[i], argv[i]); } } @@ -794,7 +794,7 @@ void read_args (int argc, char **argv) void insert_arg(int pos, char *arg_to_insert) { int i; - char *newArg = malloc (strlen (arg_to_insert)); + char *newArg = malloc (strlen (arg_to_insert)+1); strcpy(newArg, arg_to_insert); if (arg_count == arg_array_size) { @@ -816,7 +816,7 @@ void insert_arg(int pos, char *arg_to_insert) void replace_arg (char *str, int pos) { - char *newArg = malloc(strlen(str)); + char *newArg = malloc(strlen(str)+1); strcpy(newArg,str); if (confirm_changes) @@ -828,7 +828,7 @@ void replace_arg (char *str, int pos) { void append_arg (char *str) { - char *new_arg = malloc (strlen (str)); + char *new_arg = malloc (strlen (str)+1); strcpy (new_arg, str); if (confirm_changes) fprintf(stderr,"### Adding argument %s at end\n", str); @@ -862,7 +862,7 @@ void delete_arg(int pos) { void replace_optimization_level (char *new_level) { int i; int optionFound = 0; - char *new_opt = malloc(strlen(new_opt)+2); + char *new_opt = malloc(strlen(new_opt)+3); sprintf(new_opt, "-O%s",new_level); |