From: Nicholas Clark Date: Wed, 12 Mar 2008 11:46:17 +0000 (+0000) Subject: Correct logic error in PerlIOStdio_close() - 0 is an acceptable value X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1d791a44a46c93b2808774b83d9ca1f346372145;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/perlio.c b/perlio.c index d0f51d5..6459a69 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); }