about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2014-08-01 16:15:13 +0100
committerPeter Stephenson <pws@zsh.org>2014-08-01 16:15:13 +0100
commitb79ef8caaf00d5fb26fa968fd2789a3f969ab22c (patch)
tree9f1e0111c9ef462d5ee7820aab9b0897d642260e
parent417cb94fe147a94d16e3935deb83250a51cd62a8 (diff)
downloadzsh-b79ef8caaf00d5fb26fa968fd2789a3f969ab22c.tar.gz
zsh-b79ef8caaf00d5fb26fa968fd2789a3f969ab22c.tar.xz
zsh-b79ef8caaf00d5fb26fa968fd2789a3f969ab22c.zip
32932: add hmkarray() and use to fix leak
-rw-r--r--ChangeLog5
-rw-r--r--Src/subst.c2
-rw-r--r--Src/utils.c11
3 files changed, 17 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index ccad0d1ee..0c7bffe2f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-08-01  Peter Stephenson  <p.stephenson@samsung.com>
+
+	* 32932: Src/glob.c, Src/utils.c: add hmkarray() and
+	use to fix leak.
+
 2014-07-31  Barton E. Schaefer  <schaefer@zsh.org>
 
 	* 32931: Src/glob.c: with NO_NOMATCH, using a subscript glob
diff --git a/Src/subst.c b/Src/subst.c
index 471350219..d6be2f0ed 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -2935,7 +2935,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
 	     */
 	    if (!vunset) {
 		if (isarr) {
-		    aval = mkarray(NULL);
+		    aval = hmkarray(NULL);
 		} else {
 		    val = dupstring("");
 		}
diff --git a/Src/utils.c b/Src/utils.c
index aa978e6b9..998e46a36 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -3372,6 +3372,17 @@ mkarray(char *s)
 }
 
 /**/
+mod_export char **
+hmkarray(char *s)
+{
+    char **t = (char **) zhalloc((s) ? (2 * sizeof s) : (sizeof s));
+
+    if ((*t = s))
+	t[1] = NULL;
+    return t;
+}
+
+/**/
 mod_export void
 zbeep(void)
 {