Module Name:    src
Committed By:   sjg
Date:           Fri Jun 16 22:30:35 UTC 2023

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

Log Message:
make: do not allow delete of readOnly variable.

Sometimes we mark a variable readOnly to guard against .undef


To generate a diff of this commit:
cvs rdiff -u -r1.1055 -r1.1056 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.1055 src/usr.bin/make/var.c:1.1056
--- src/usr.bin/make/var.c:1.1055	Thu Jun  1 07:44:10 2023
+++ src/usr.bin/make/var.c	Fri Jun 16 22:30:35 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1055 2023/06/01 07:44:10 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1056 2023/06/16 22:30:35 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1055 2023/06/01 07:44:10 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1056 2023/06/16 22:30:35 sjg Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -513,6 +513,11 @@ Var_Delete(GNode *scope, const char *var
 
 	DEBUG2(VAR, "%s: delete %s\n", scope->name, varname);
 	v = he->value;
+	if (v->readOnly) {
+		DEBUG2(VAR, "%s: delete %s (readOnly)\n",
+		    scope->name, varname);
+		return;
+	}
 	if (v->inUse) {
 		Parse_Error(PARSE_FATAL,
 		    "Cannot delete variable \"%s\" while it is used",

Reply via email to