about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>2018-07-31 22:15:58 +0900
committerJun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>2018-07-31 22:15:58 +0900
commitbaedd62f0d601bf03d99b2366a8ace42268e88ed (patch)
tree82add95fcfcf764c535b2b3ee126eb012ba5b648
parente6f2d776d3ce582533fc6177082270872fcf67a3 (diff)
downloadzsh-baedd62f0d601bf03d99b2366a8ace42268e88ed.tar.gz
zsh-baedd62f0d601bf03d99b2366a8ace42268e88ed.tar.xz
zsh-baedd62f0d601bf03d99b2366a8ace42268e88ed.zip
43219 (except term{cap,info}.c): fix several memory leaks
-rw-r--r--ChangeLog6
-rw-r--r--Src/Modules/db_gdbm.c5
-rw-r--r--Src/Modules/pcre.c1
-rw-r--r--Src/Zle/compcore.c2
-rw-r--r--Src/init.c3
-rw-r--r--Src/math.c2
-rw-r--r--Src/subst.c2
7 files changed, 17 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 465320208..e8acff0eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2018-07-31  Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
+
+	* 43219 (except term{cap,info}.c): Src/Modules/db_gdbm.c,
+	Src/Modules/pcre.c, Src/Zle/compcore.c, Src/init.c, Src/math.c,
+	Src/subst.c: fix several memory leaks
+
 2018-07-30  Peter Stephenson  <p.stephenson@samsung.com>
 
 	* 43225: Src/Zle/zle_main.c: recalculate timeout after calling
diff --git a/Src/Modules/db_gdbm.c b/Src/Modules/db_gdbm.c
index 5f776f407..ed702b912 100644
--- a/Src/Modules/db_gdbm.c
+++ b/Src/Modules/db_gdbm.c
@@ -359,7 +359,7 @@ gdbmsetfn(Param pm, char *val)
     }
 
     if (val) {
-        pm->u.str = ztrdup(val);
+        pm->u.str = val;
         pm->node.flags |= PM_UPTODATE;
     }
 
@@ -732,6 +732,9 @@ static int remove_tied_name( const char *name ) {
         p++;
     }
 
+    if (*p)
+	zsfree(*p);
+
     /* Copy x+1 to x */
     while (*p) {
         *p=*(p+1);
diff --git a/Src/Modules/pcre.c b/Src/Modules/pcre.c
index 15ee34bc8..6289e003e 100644
--- a/Src/Modules/pcre.c
+++ b/Src/Modules/pcre.c
@@ -380,6 +380,7 @@ bin_pcre_match(char *nam, char **args, Options ops, UNUSED(int func))
     
     if (ovec)
 	zfree(ovec, ovecsize*sizeof(int));
+    zsfree(plaintext);
 
     return return_value;
 }
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index fd415da89..8eca39447 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -3556,6 +3556,8 @@ freematches(Cmgroup g, int cm)
 	    }
 	    free(g->expls);
 	}
+	if (g->widths)
+	    free(g->widths);
 	zsfree(g->name);
 	free(g);
 
diff --git a/Src/init.c b/Src/init.c
index c5372665a..e9e6be9b4 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -459,7 +459,8 @@ parseopts(char *nam, char ***argvp, char *new_opts, char **cmdp,
 		/* -c command */
 		*cmdp = *argv;
 		new_opts[INTERACTIVE] &= 1;
-		scriptname = scriptfilename = ztrdup("zsh");
+		if (toplevel)
+		    scriptname = scriptfilename = ztrdup("zsh");
 	    } else if (**argv == 'o') {
 		if (!*++*argv)
 		    argv++;
diff --git a/Src/math.c b/Src/math.c
index 32bccc6e9..4b7ecf0ab 100644
--- a/Src/math.c
+++ b/Src/math.c
@@ -535,7 +535,7 @@ lexconstant(void)
 	for (ptr2 = ptr; ptr2 < nptr; ptr2++) {
 	    if (*ptr2 == '_') {
 		int len = nptr - ptr;
-		ptr = ztrdup(ptr);
+		ptr = dupstring(ptr);
 		for (ptr2 = ptr; len; len--) {
 		    if (*ptr2 == '_')
 			chuck(ptr2);
diff --git a/Src/subst.c b/Src/subst.c
index a265a187e..c1021fbf3 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -3169,7 +3169,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
 		    zip = hmkarray(sval);
 	    }
 	    if (!isarr) {
-		aval = mkarray(val);
+		aval = hmkarray(val);
 		isarr = 1;
 	    }
 	    if (zip) {