summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-03-12 11:46:17 +0000
committerNicholas Clark <nick@ccl4.org>2008-03-12 11:46:17 +0000
commit1d791a44a46c93b2808774b83d9ca1f346372145 (patch)
tree68c3ccc8e38a6a0db41179f1b9bb06b951e31f32 /perlio.c
parent89e382121886b3fe97bf9b7381d1b1849bea6bda (diff)
downloadperl-1d791a44a46c93b2808774b83d9ca1f346372145.tar.gz
Correct logic error in PerlIOStdio_close() - 0 is an acceptable value
from dup(), so it can't also be the "don't do anything later" value. p4raw-id: //depot/perl@33491
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/perlio.c b/perlio.c
index d0f51d5bf0..6459a69672 100644
--- a/perlio.c
+++ b/perlio.c
@@ -3130,7 +3130,7 @@ PerlIOStdio_close(pTHX_ PerlIO *f)
int invalidate = 0;
IV result = 0;
int saveerr = 0;
- int dupfd = 0;
+ int dupfd = -1;
#ifdef SOCKS5_VERSION_NAME
/* Socks lib overrides close() but stdio isn't linked to
that library (though we are) - so we must call close()
@@ -3171,7 +3171,7 @@ PerlIOStdio_close(pTHX_ PerlIO *f)
/* in SOCKS' case, let close() determine return value */
result = close(fd);
#endif
- if (dupfd) {
+ if (dupfd >= 0) {
PerlLIO_dup2(dupfd,fd);
PerlLIO_close(dupfd);
}