From 0848b7534ed918503c36a4b217ab5f6053805763 Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Mon, 4 Mar 2024 21:21:20 -0800 Subject: 52659: Fix crash on unset-through-nameref, add regression test --- Src/builtin.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Src') 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; } } -- cgit 1.4.1