From 8bbdbb02b30ffd39c2fac9259b3a91cb62e1711d Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sun, 13 Oct 2002 18:50:10 +0000 Subject: 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. --- commands.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'commands.c') 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) { -- cgit v1.2.3