mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-05-20 06:56:05 +02:00
34490: Fix leak on print -zf/-sf error
This commit is contained in:
parent
2dbbc88d0b
commit
0209635832
|
@ -3,6 +3,8 @@
|
|||
* 34488: Src/builtin.c: Fix use-after-free for print -zf and
|
||||
print -sf
|
||||
|
||||
* 34490: Src/builtin.c: Fix leak on print -zf/-sf error
|
||||
|
||||
2015-02-09 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
||||
* 34485: Src/exec.c, Src/parse.c, Test/E01options.ztst:
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue