diff options
author | Peter Stephenson <pws@zsh.org> | 2014-09-29 17:17:26 +0100 |
---|---|---|
committer | Peter Stephenson <pws@zsh.org> | 2014-09-29 17:17:26 +0100 |
commit | f2aaea5cd31fcca6f060e1de0cb1e91c05c716bb (patch) | |
tree | d9fa45066808a4aadb1bb633f3f4d0c68c3bbac0 /Src | |
parent | 546203a770cec329e73781c3c8ab1078390aee72 (diff) | |
download | zsh-f2aaea5cd31fcca6f060e1de0cb1e91c05c716bb.tar.gz zsh-f2aaea5cd31fcca6f060e1de0cb1e91c05c716bb.tar.xz zsh-f2aaea5cd31fcca6f060e1de0cb1e91c05c716bb.zip |
users/19183: improve unlikely error case with fdopen in history code
Diffstat (limited to 'Src')
-rw-r--r-- | Src/hist.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Src/hist.c b/Src/hist.c index d29a65afe..4660fd073 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -2593,7 +2593,12 @@ savehistfile(char *fn, int err, int writeflags) out = NULL; } else { int fd = open(tmpfile, O_CREAT | O_WRONLY | O_EXCL, 0600); - out = fd >= 0 ? fdopen(fd, "w") : NULL; + if (fd >=0) { + out = fdopen(fd, "w"); + if (!out) + close(fd); + } else + out = NULL; } #ifdef HAVE_FCHMOD |