summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--Src/exec.c6
2 files changed, 8 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 2afb52cc2..f54188af9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2015-01-06  Mikael Magnusson  <mikachu@gmail.com>
 
+	* 34134: Src/exec.c: anon funcs: don't leak shf and related data
+
 	* 34112: Src/builtin.c: typeset: fix leak of oldval
 
 	* 34106: Src/hist.c: use zhtricat instead of tricat
diff --git a/Src/exec.c b/Src/exec.c
index 6b93008bd..ab9291024 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -4461,6 +4461,11 @@ execfuncdef(Estate state, Eprog redir_prog)
 	    if (htok && args) {
 		execsubst(args);
 		if (errflag) {
+		    freeeprog(shf->funcdef);
+		    if (shf->redir) /* shouldn't be */
+			freeeprog(shf->redir);
+		    zsfree(shf->filename);
+		    zfree(shf, sizeof(*shf));
 		    state->pc = end;
 		    return 1;
 		}
@@ -4486,6 +4491,7 @@ execfuncdef(Estate state, Eprog redir_prog)
 		(signum = getsignum(s + 4)) != -1) {
 		if (settrap(signum, NULL, ZSIG_FUNC)) {
 		    freeeprog(shf->funcdef);
+		    zsfree(shf->filename);
 		    zfree(shf, sizeof(*shf));
 		    state->pc = end;
 		    return 1;