summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2009-08-02 16:05:42 +0000
committerPaul Smith <psmith@gnu.org>2009-08-02 16:05:42 +0000
commit7deb42aafdf547a3648f60ff04e0114c10a3d18d (patch)
tree9330340bfd24da63b6bf280a1977bfc0f2d6d0a3 /variable.c
parente2f16fdf45ec0506c68f32e9fc6a7b31ae17fdc6 (diff)
downloadgunmake-7deb42aafdf547a3648f60ff04e0114c10a3d18d.tar.gz
- Fix Savannah bug #27093
- Fix Savannah bug #27143 - Fix Savannah bug #23960 - Fix Savannah bug #27148
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/variable.c b/variable.c
index 92a96ec..10bbc54 100644
--- a/variable.c
+++ b/variable.c
@@ -1091,7 +1091,7 @@ do_variable_definition (const struct floc *flocp, const char *varname,
unsigned int oldlen, vallen;
const char *val;
- char *tp;
+ char *tp = NULL;
val = value;
if (v->recursive)
@@ -1104,15 +1104,17 @@ do_variable_definition (const struct floc *flocp, const char *varname,
when it was set; and from the expanded new value. Allocate
memory for the expansion as we may still need the rest of the
buffer if we're looking at a target-specific variable. */
- val = alloc_value = allocated_variable_expand (val);
+ val = tp = allocated_variable_expand (val);
oldlen = strlen (v->value);
vallen = strlen (val);
- tp = alloca (oldlen + 1 + vallen + 1);
- memcpy (tp, v->value, oldlen);
- tp[oldlen] = ' ';
- memcpy (&tp[oldlen + 1], val, vallen + 1);
- p = tp;
+ p = alloc_value = xmalloc (oldlen + 1 + vallen + 1);
+ memcpy (alloc_value, v->value, oldlen);
+ alloc_value[oldlen] = ' ';
+ memcpy (&alloc_value[oldlen + 1], val, vallen + 1);
+
+ if (tp)
+ free (tp);
}
}
}
@@ -1220,10 +1222,10 @@ do_variable_definition (const struct floc *flocp, const char *varname,
}
else
{
- if (alloc_value)
- free (alloc_value);
+ char *tp = alloc_value;
alloc_value = allocated_variable_expand (p);
+
if (find_and_set_default_shell (alloc_value))
{
v = define_variable_in_set (varname, strlen (varname), p,
@@ -1236,6 +1238,9 @@ do_variable_definition (const struct floc *flocp, const char *varname,
}
else
v = lookup_variable (varname, strlen (varname));
+
+ if (tp)
+ free (tp);
}
}
else