about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJun. T <takimoto-j@kba.biglobe.ne.jp>2024-08-06 14:37:39 -0700
committerBart Schaefer <schaefer@zsh.org>2024-08-06 14:37:39 -0700
commitb2f24ff0d2a9631f331c1841491ce60e69c20ca6 (patch)
tree4969d858ccb3dec625c9de45e5fedf0f8ab07e98
parent72751bfe1f9e37145c12e244ebb1729c27aff901 (diff)
downloadzsh-b2f24ff0d2a9631f331c1841491ce60e69c20ca6.tar.gz
zsh-b2f24ff0d2a9631f331c1841491ce60e69c20ca6.tar.xz
zsh-b2f24ff0d2a9631f331c1841491ce60e69c20ca6.zip
53026: fix failure to free old value when setting new value of reference
-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;