about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@gmail.com>2015-02-10 08:10:25 +0100
committerMikael Magnusson <mikachu@gmail.com>2015-02-10 13:03:51 +0100
commit0209635832f519401ce9c45b675ef871be105cfc (patch)
tree587d07baf931354f60ed5f6abeaddc19ecca596e /Src
parent2dbbc88d0b78c3fc2fb8e63fba67119c5aa456fc (diff)
downloadzsh-0209635832f519401ce9c45b675ef871be105cfc.tar.gz
zsh-0209635832f519401ce9c45b675ef871be105cfc.tar.xz
zsh-0209635832f519401ce9c45b675ef871be105cfc.zip
34490: Fix leak on print -zf/-sf error
Diffstat (limited to 'Src')
-rw-r--r--Src/builtin.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index e093cbe32..c4e4b94fd 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3732,7 +3732,7 @@ bin_print(char *name, char **args, Options ops, int func)
     int flen, width, prec, type, argc, n, narg, curlen = 0;
     int nnl = 0, fmttrunc = 0, ret = 0, maxarg = 0, nc = 0;
     int flags[5], *len;
-    char *start, *endptr, *c, *d, *flag, *buf, spec[13], *fmt = NULL;
+    char *start, *endptr, *c, *d, *flag, *buf = NULL, spec[13], *fmt = NULL;
     char **first, **argp, *curarg, *flagch = "0+- #", save = '\0', nullstr = '\0';
     size_t rcount, count = 0;
 #ifdef HAVE_OPEN_MEMSTREAM
@@ -4214,6 +4214,10 @@ bin_print(char *name, char **args, Options ops, int func)
 				 narg);
 			if (fout != stdout)
 			    fclose(fout);
+#ifdef HAVE_OPEN_MEMSTREAM
+			if (buf)
+			    free(buf);
+#endif
 			return 1;
 		    } else {
 		    	if (narg > maxarg) maxarg = narg;
@@ -4247,6 +4251,10 @@ bin_print(char *name, char **args, Options ops, int func)
 				     narg);
 			    if (fout != stdout)
 				fclose(fout);
+#ifdef HAVE_OPEN_MEMSTREAM
+			    if (buf)
+				free(buf);
+#endif
 			    return 1;
 			} else {
 		    	    if (narg > maxarg) maxarg = narg;
@@ -4276,6 +4284,10 @@ bin_print(char *name, char **args, Options ops, int func)
 					 narg);
 				if (fout != stdout)
 				    fclose(fout);
+#ifdef HAVE_OPEN_MEMSTREAM
+				if (buf)
+				    free(buf);
+#endif
 				return 1;
 			    } else {
 		    		if (narg > maxarg) maxarg = narg;
@@ -4431,6 +4443,10 @@ bin_print(char *name, char **args, Options ops, int func)
 		    (fflush(fout) != 0 && errno != EBADF)) {
 		    zwarnnam(name, "write error: %e", errno);
 		}
+#ifdef HAVE_OPEN_MEMSTREAM
+		if (buf)
+		    free(buf);
+#endif
 		return 1;
 	    }