From: Doug MacEachern Date: Thu, 22 Jun 2000 23:08:06 +0000 (-0700) Subject: Avoid double close(). X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=38432390e2d661c3ff293a77cd8d04f802667992;p=p5sagit%2Fp5-mst-13.2.git Avoid double close(). Subject: [PATCH] avoid double close() Message-ID: p4raw-id: //depot/cfgperl@6223 --- diff --git a/doio.c b/doio.c index 970eaed..6f62144 100644 --- a/doio.c +++ b/doio.c @@ -504,8 +504,8 @@ Perl_do_open9(pTHX_ GV *gv, register char *name, I32 len, int as_raw, IoFLAGS(io) &= ~IOf_NOLINE; if (writing) { dTHR; - if (IoTYPE(io) == 's' - || (IoTYPE(io) == '>' && S_ISCHR(PL_statbuf.st_mode)) ) + bool is_reg = IoTYPE(io) == '>' && S_ISCHR(PL_statbuf.st_mode); + if (IoTYPE(io) == 's' || is_reg) { char *mode; if (out_raw) @@ -520,6 +520,10 @@ Perl_do_open9(pTHX_ GV *gv, register char *name, I32 len, int as_raw, IoIFP(io) = Nullfp; goto say_false; } + else { + if (is_reg) + IoIFP(io) = IoOFP(io); /* avoid double close() */ + } } else IoOFP(io) = fp;