Module Name:    src
Committed By:   rillig
Date:           Sat Sep 12 23:12:44 UTC 2020

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

Log Message:
make(1): fix assertion failure in Dir_Destroy in -DCLEANUP mode

When the openDirectories path list is cleaned up, each path from it is
first dequeued and then freed via Dir_Destroy.  At this point, the path
is no longer in openDirectories, which triggered an assertion in
Lst_Remove, called by Dir_Destroy.


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.141 src/usr.bin/make/dir.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/dir.c
diff -u src/usr.bin/make/dir.c:1.140 src/usr.bin/make/dir.c:1.141
--- src/usr.bin/make/dir.c:1.140	Sat Sep 12 12:24:21 2020
+++ src/usr.bin/make/dir.c	Sat Sep 12 23:12:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.140 2020/09/12 12:24:21 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.141 2020/09/12 23:12:44 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.140 2020/09/12 12:24:21 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.141 2020/09/12 23:12:44 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)dir.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: dir.c,v 1.140 2020/09/12 12:24:21 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.141 2020/09/12 23:12:44 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1656,10 +1656,11 @@ Dir_Destroy(void *pp)
     p->refCount -= 1;
 
     if (p->refCount == 0) {
-	LstNode ln;
+	LstNode node;
 
-	ln = Lst_FindDatum(openDirectories, p);
-	Lst_Remove(openDirectories, ln);
+	node = Lst_FindDatum(openDirectories, p);
+	if (node != NULL)
+	    Lst_Remove(openDirectories, node);
 
 	Hash_DeleteTable(&p->files);
 	free(p->name);

Reply via email to