about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/builtin.c6
2 files changed, 9 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index e9bc0d9c5..11cc8dd6b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-02-17  Bart Schaefer  <schaefer@zsh.org>
+
+	* 52556: Src/builtin.c: fix crash when applying a type change via
+	a named reference when the referent has been declared but unset
+
 2024-02-16  Mikael Magnusson  <mikachu@gmail.com>
 
 	* 52546: Functions/Zle/incarg: incarg: avoid unneeded subshell
diff --git a/Src/builtin.c b/Src/builtin.c
index 5c5adb9d3..dd352c146 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2031,8 +2031,10 @@ typeset_single(char *cname, char *pname, Param pm, int func,
     char *subscript;
 
     if (pm && (pm->node.flags & PM_NAMEREF) && !((off|on) & PM_NAMEREF)) {
-	if (!(off & PM_NAMEREF))
-	    pm = (Param)resolve_nameref(pm, NULL);
+	if (!(off & PM_NAMEREF)) {
+	    if ((pm = (Param)resolve_nameref(pm, NULL)))
+		pname = pm->node.nam;
+	}
 	if (pm && (pm->node.flags & PM_NAMEREF) &&
 	    (on & ~(PM_NAMEREF|PM_LOCAL|PM_READONLY))) {
 	    /* Changing type of PM_SPECIAL|PM_AUTOLOAD is a fatal error.  *