summaryrefslogtreecommitdiffstats
path: root/usr.bin/make
diff options
context:
space:
mode:
authorjmallett <jmallett@FreeBSD.org>2002-10-24 04:10:55 +0000
committerjmallett <jmallett@FreeBSD.org>2002-10-24 04:10:55 +0000
commit18683e79422083dfc0130e90e83679a17ef8e64e (patch)
tree95ee87d0c3d1f611ed09c99fdec2620b405c4b6e /usr.bin/make
parentaa8a30727169eb2276db852bfd7bf40cf0f235fd (diff)
downloadFreeBSD-src-18683e79422083dfc0130e90e83679a17ef8e64e.zip
FreeBSD-src-18683e79422083dfc0130e90e83679a17ef8e64e.tar.gz
Duplicate the variable name in the v->name field, as otherwise it points to
data that will be modified. And do the appropriate thing now and free the v->name buffer along with other relinquished memory. XXX There is duplication here of destroying a Var, which is probably bogus, and probably missed in a few places.
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/var.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index 3bd17ca..aab2bf1 100644
--- a/usr.bin/make/var.c
+++ b/usr.bin/make/var.c
@@ -1631,7 +1631,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
* so kludge up a Var structure for the modifications
*/
v = (Var *) emalloc(sizeof(Var));
- v->name = &str[1];
+ v->name = estrdup(str);
v->val = Buf_Init(1);
v->flags = VAR_JUNK;
}
@@ -2201,6 +2201,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
*/
*freePtr = TRUE;
}
+ free(v->name);
Buf_Destroy(v->val, destroy);
free(v);
} else if (v->flags & VAR_JUNK) {
@@ -2212,6 +2213,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
free(str);
}
*freePtr = FALSE;
+ free(v->name);
Buf_Destroy(v->val, TRUE);
free(v);
if (dynamic) {
OpenPOWER on IntegriCloud