about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/params.c3
2 files changed, 7 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 2fa2f51a3..667f17177 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-08-06  Bart Schaefer  <schaefer@zsh.org>
+
+	* Jun.T: 53026: Src/params.c: fix failure to free old value when
+	setting new value of reference
+
 2024-08-05  Bart Schaefer  <schaefer@zsh.org>
 
 	* 53025: Src/loop.c, Src/params.c: fix two memory leaks and two
diff --git a/Src/params.c b/Src/params.c
index f143a790f..acd577527 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -482,7 +482,8 @@ static initparam argvparam_pm = IPDEF9("", &pparams, NULL, \
 #define GETREFNAME(PM) (((PM)->node.flags & PM_SPECIAL) ?	\
 			(PM)->gsu.s->getfn(PM) : (PM)->u.str)
 #define SETREFNAME(PM,S) (((PM)->node.flags & PM_SPECIAL) ?		\
-			  (PM)->gsu.s->setfn(PM,(S)) : ((PM)->u.str = (S)))
+			  (PM)->gsu.s->setfn(PM,(S)) :			\
+			  (zsfree((PM)->u.str), (PM)->u.str = (S)))
 
 static Param argvparam;