summaryrefslogtreecommitdiff
path: root/usr.bin/make/parse.c
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2022-01-09 12:43:52 +0000
committerrillig <rillig@NetBSD.org>2022-01-09 12:43:52 +0000
commit377c8a2a59ba908e95cb1f0252d96558e470055e (patch)
tree132617c8c6f731b9ae99e4f6d8ce796a04d03515 /usr.bin/make/parse.c
parentb793ac0e782f9e5559aeb69560bec7dc607ec9f0 (diff)
make: fix use-after-free in -dp mode (since yesterday)
In a .for loop that contains an unclosed .if directive, Cond_restore_depth generates an error message. If stack traces are enabled using the option '-dp', the details of the .for loop are added to the stack trace, but at that point, the ForLoop had already been freed. To reproduce: make-2022.01.09.00.33.57 -r -f unit-tests/directive-for.mk -dp
Diffstat (limited to 'usr.bin/make/parse.c')
-rw-r--r--usr.bin/make/parse.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c
index e10869dbc5a..f7f9c814c7a 100644
--- a/usr.bin/make/parse.c
+++ b/usr.bin/make/parse.c
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.646 2022/01/09 11:43:58 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.647 2022/01/09 12:43:52 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.646 2022/01/09 11:43:58 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.647 2022/01/09 12:43:52 rillig Exp $");
/*
* A file being read.
@@ -2253,6 +2253,8 @@ ParseEOF(void)
FStr_Done(&curFile->name);
Buf_Done(&curFile->buf);
+ if (curFile->forLoop != NULL)
+ ForLoop_Free(curFile->forLoop);
Vector_Pop(&includes);
if (includes.len == 0) {