summaryrefslogtreecommitdiff
path: root/job.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2012-09-09 23:25:07 +0000
committerPaul Smith <psmith@gnu.org>2012-09-09 23:25:07 +0000
commita94b0b0ea58767eb204a1ebc8fb30b913d66a64c (patch)
treef6bb8e30d9d5817373541f5d84d06bc6d8ee27a1 /job.c
parentb9c4a38022e5238356957bba6c2ffaef7a219a23 (diff)
downloadgunmake-a94b0b0ea58767eb204a1ebc8fb30b913d66a64c.tar.gz
Keep the command line on the heap to avoid stack overflow.
Fixes Savannah bug #36451.
Diffstat (limited to 'job.c')
-rw-r--r--job.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/job.c b/job.c
index 754576b..f7b7d51 100644
--- a/job.c
+++ b/job.c
@@ -2984,8 +2984,8 @@ construct_command_argv_internal (char *line, char **restp, char *shell,
return new_argv;
}
- new_line = alloca ((shell_len*2) + 1 + sflags_len + 1
- + (line_len*2) + 1);
+ new_line = xmalloc ((shell_len*2) + 1 + sflags_len + 1
+ + (line_len*2) + 1);
ap = new_line;
/* Copy SHELL, escaping any characters special to the shell. If
we don't escape them, construct_command_argv_internal will
@@ -3052,8 +3052,11 @@ construct_command_argv_internal (char *line, char **restp, char *shell,
*ap++ = *p;
}
if (ap == new_line + shell_len + sflags_len + 2)
- /* Line was empty. */
- return 0;
+ {
+ /* Line was empty. */
+ free (new_line);
+ return 0;
+ }
*ap = '\0';
#ifdef WINDOWS32
@@ -3194,6 +3197,8 @@ construct_command_argv_internal (char *line, char **restp, char *shell,
fatal (NILF, _("%s (line %d) Bad shell context (!unixy && !batch_mode_shell)\n"),
__FILE__, __LINE__);
#endif
+
+ free (new_line);
}
#endif /* ! AMIGA */