summaryrefslogtreecommitdiff
path: root/commands.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2002-10-13 18:50:10 +0000
committerPaul Smith <psmith@gnu.org>2002-10-13 18:50:10 +0000
commit8bbdbb02b30ffd39c2fac9259b3a91cb62e1711d (patch)
tree19aedce81b831b1ad57c3b0fef27589070dc879c /commands.c
parent47cd8d4624b60d3462991c436c961e0721cd278b (diff)
downloadgunmake-8bbdbb02b30ffd39c2fac9259b3a91cb62e1711d.tar.gz
Fix bug#1379: don't use alloca() where it could overrun the stack size.
Implemented enhancement #1391: allow "export" in target-specific variable definitions. Change the Info name of the "Automatic" node to "Automatic Variables". Add text clarifying the scope of automatic variables to that section.
Diffstat (limited to 'commands.c')
-rw-r--r--commands.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/commands.c b/commands.c
index 84b58de..a0483c4 100644
--- a/commands.c
+++ b/commands.c
@@ -127,11 +127,12 @@ set_file_variables (file)
/* Compute the values for $^, $+, $?, and $|. */
{
+ static char *plus_value=0, *bar_value=0, *qmark_value=0;
+ static int qmark_max=0, plus_max=0, bar_max=0;
+
unsigned int qmark_len, plus_len, bar_len;
- char *caret_value, *plus_value;
char *cp;
- char *qmark_value;
- char *bar_value;
+ char *caret_value;
char *qp;
char *bp;
struct dep *d;
@@ -147,7 +148,9 @@ set_file_variables (file)
if (plus_len == 0)
plus_len++;
- cp = plus_value = (char *) alloca (plus_len);
+ if (plus_len > plus_max)
+ plus_value = (char *) xmalloc (plus_max = plus_len);
+ cp = plus_value;
qmark_len = plus_len + 1; /* Will be this or less. */
for (d = file->deps; d != 0; d = d->next)
@@ -193,8 +196,14 @@ set_file_variables (file)
/* Compute the values for $^, $?, and $|. */
cp = caret_value = plus_value; /* Reuse the buffer; it's big enough. */
- qp = qmark_value = (char *) alloca (qmark_len);
- bp = bar_value = (char *) alloca (bar_len);
+
+ if (qmark_len > qmark_max)
+ qmark_value = (char *) xmalloc (qmark_max = qmark_len);
+ qp = qmark_value;
+
+ if (bar_len > bar_max)
+ bar_value = (char *) xmalloc (bar_max = bar_len);
+ bp = bar_value;
for (d = file->deps; d != 0; d = d->next)
{