Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): clean up memory handling in VarAssign_...
details: https://anonhg.NetBSD.org/src/rev/88f34436d9d7
branches: trunk
changeset: 958021:88f34436d9d7
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Dec 20 14:52:16 2020 +0000
description:
make(1): clean up memory handling in VarAssign_EvalShell
diffstat:
usr.bin/make/parse.c | 26 +++++++++++++-------------
1 files changed, 13 insertions(+), 13 deletions(-)
diffs (57 lines):
diff -r 238d967f7780 -r 88f34436d9d7 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Sun Dec 20 14:48:35 2020 +0000
+++ b/usr.bin/make/parse.c Sun Dec 20 14:52:16 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.506 2020/12/20 14:48:35 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.507 2020/12/20 14:52:16 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.506 2020/12/20 14:48:35 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.507 2020/12/20 14:52:16 rillig Exp $");
/* types and constants */
@@ -1962,27 +1962,27 @@
VarAssign_EvalShell(const char *name, const char *uvalue, GNode *ctxt,
FStr *out_avalue)
{
- const char *cmd, *errfmt;
+ FStr cmd;
+ const char *errfmt;
char *cmdOut;
- void *cmd_freeIt = NULL;
-
- cmd = uvalue;
- if (strchr(cmd, '$') != NULL) {
- char *ecmd;
- (void)Var_Subst(cmd, VAR_CMDLINE, VARE_WANTRES | VARE_UNDEFERR,
- &ecmd);
+
+ cmd = FStr_InitRefer(uvalue);
+ if (strchr(cmd.str, '$') != NULL) {
+ char *expanded;
+ (void)Var_Subst(cmd.str, VAR_CMDLINE,
+ VARE_WANTRES | VARE_UNDEFERR, &expanded);
/* TODO: handle errors */
- cmd = cmd_freeIt = ecmd;
+ cmd = FStr_InitOwn(expanded);
}
- cmdOut = Cmd_Exec(cmd, &errfmt);
+ cmdOut = Cmd_Exec(cmd.str, &errfmt);
Var_Set(name, cmdOut, ctxt);
*out_avalue = FStr_InitOwn(cmdOut);
if (errfmt != NULL)
Parse_Error(PARSE_WARNING, errfmt, cmd);
- free(cmd_freeIt);
+ FStr_Done(&cmd);
}
/* Perform a variable assignment.
Home |
Main Index |
Thread Index |
Old Index