about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorBart Schaefer <schaefer@zsh.org>2024-03-04 21:21:20 -0800
committerBart Schaefer <schaefer@zsh.org>2024-03-04 21:21:20 -0800
commit0848b7534ed918503c36a4b217ab5f6053805763 (patch)
tree6ae395db6de0b0765fb9ada1447515f799473700 /Src
parent700f675bf0dcd89f685b9c87b416ecb2e40e6a55 (diff)
downloadzsh-0848b7534ed918503c36a4b217ab5f6053805763.tar.gz
zsh-0848b7534ed918503c36a4b217ab5f6053805763.tar.xz
zsh-0848b7534ed918503c36a4b217ab5f6053805763.zip
52659: Fix crash on unset-through-nameref, add regression test
Diffstat (limited to 'Src')
-rw-r--r--Src/builtin.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index ba9cb03c2..0aae1fcde 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3935,9 +3935,11 @@ bin_unset(char *name, char **argv, Options ops, int func)
 		int ref = (pm->node.flags & PM_NAMEREF);
 		if (!(pm = (Param)resolve_nameref(pm, NULL)))
 		    continue;
-		if (ref && pm->level < locallevel) {
+		if (ref && pm->level < locallevel &&
+		    !(pm->node.flags & PM_READONLY)) {
 		    /* Just mark unset, do not remove from table */
-		    pm->node.flags |= PM_DECLARED|PM_UNSET;
+		    stdunsetfn(pm, 0);
+		    pm->node.flags |= PM_DECLARED;
 		    continue;
 		}
 	    }