From a66668aabccfbae3e1f22eaeb897b9c7a1e02733 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Mon, 22 Feb 1999 07:23:30 +0000 Subject: * New feature: .LIBPATTERNS controls the way -lfoo dependencies are expanded. * A few tweaks to the system glob test, after trying it on a system where it's true. * Installed patches to archive handling for AIX 4.3 big archives. * Fix a memory stomp in target-specific variables. * Fix a memory leak in foreach functions. --- variable.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'variable.c') diff --git a/variable.c b/variable.c index 85987db..648f82b 100644 --- a/variable.c +++ b/variable.c @@ -265,6 +265,8 @@ pop_variable_scope () next = v->next; free (v->name); + if (v->value) + free (v->value); free ((char *) v); } } @@ -687,7 +689,7 @@ try_variable_definition (flocp, line, origin) register char *end; enum { f_bogus, f_simple, f_recursive, f_append, f_conditional } flavor = f_bogus; - char *name, *expanded_name, *value; + char *name, *expanded_name, *value, *alloc_value=NULL; struct variable *v; while (1) @@ -775,8 +777,11 @@ try_variable_definition (flocp, line, origin) /* Should not be possible. */ abort (); case f_simple: - /* A simple variable definition "var := value". Expand the value. */ - value = variable_expand (p); + /* A simple variable definition "var := value". Expand the value. + We have to allocate memory since otherwise it'll clobber the + variable buffer, and we still need that. */ + alloc_value = allocated_variable_expand (p); + value = alloc_value; break; case f_conditional: /* A conditional variable definition "var ?= value". @@ -931,6 +936,8 @@ try_variable_definition (flocp, line, origin) v = define_variable (expanded_name, strlen (expanded_name), value, origin, flavor == f_recursive); + if (alloc_value) + free (alloc_value); free (expanded_name); return v; -- cgit v1.2.3