Module Name:    src
Committed By:   rillig
Date:           Mon Dec 13 04:18:01 UTC 2021

Modified Files:
        src/usr.bin/make: var.c

Log Message:
make: fix memory leak when parsing a variable name

To trigger the memory leak, the expanded variable name must not be a
prefix of the textual variable name.

        textual name            expanded name
ok:     UNDEF.${undef}          UNDEF.
leak:   UNDEF.${undef}.         UNDEF..


To generate a diff of this commit:
cvs rdiff -u -r1.985 -r1.986 src/usr.bin/make/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.985 src/usr.bin/make/var.c:1.986
--- src/usr.bin/make/var.c:1.985	Mon Dec 13 03:55:16 2021
+++ src/usr.bin/make/var.c	Mon Dec 13 04:18:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.985 2021/12/13 03:55:16 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.986 2021/12/13 04:18:01 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.985 2021/12/13 03:55:16 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.986 2021/12/13 04:18:01 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -4433,6 +4433,7 @@ ParseVarnameLong(
 			*out_false_pp = p;
 			*out_false_res = EvalUndefined(dynamic, start, p,
 			    name, emode, out_false_val);
+			LazyBuf_Done(&varname);
 			return false;
 		}
 

Reply via email to