diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2009-09-21 20:49:21 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2009-09-21 20:49:21 +0000 |
commit | 997eafdcad85e9a2c59db1141b404dd4c4bcb22d (patch) | |
tree | 81c176a54511da8009c70900063e4ba228fe0988 /Src | |
parent | e85349fbf793f18211d9280ca80ec8911e05c708 (diff) | |
download | zsh-997eafdcad85e9a2c59db1141b404dd4c4bcb22d.tar.gz zsh-997eafdcad85e9a2c59db1141b404dd4c4bcb22d.tar.xz zsh-997eafdcad85e9a2c59db1141b404dd4c4bcb22d.zip |
27283: failure to dup fd caused mayhem
Diffstat (limited to 'Src')
-rw-r--r-- | Src/exec.c | 1 | ||||
-rw-r--r-- | Src/utils.c | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/Src/exec.c b/Src/exec.c index e68237948..ca9cf0f4d 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -1980,6 +1980,7 @@ addfd(int forked, int *save, struct multio **mfds, int fd1, int fd2, int rflag, */ if (fdN < 0 && errno != EBADF) { zerr("cannot duplicate fd %d: %e", fd1, errno); + mfds[fd1] = NULL; closemnodes(mfds); return; } diff --git a/Src/utils.c b/Src/utils.c index ad4ffca92..a12914787 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -1631,7 +1631,8 @@ movefd(int fd) #else int fe = movefd(dup(fd)); #endif - zclose(fd); + if (fe != -1) + zclose(fd); fd = fe; } if(fd != -1) { |