From: Nick Ing-Simmons Date: Sat, 3 Nov 2001 10:27:34 +0000 (+0000) Subject: Fix clone_leak problem. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6124d23f33100dc3c406774873984a1b51f6ab02;p=p5sagit%2Fp5-mst-13.2.git Fix clone_leak problem. PerlIOStdio_dup was leaking FILE * as it was still doing fdopen() as vestige of calling PerlLIO_dup(). p4raw-id: //depot/perlio@12830 --- diff --git a/perlio.c b/perlio.c index f08ba48..c960a03 100644 --- a/perlio.c +++ b/perlio.c @@ -2480,23 +2480,10 @@ PerlIOStdio_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param) /* This assumes no layers underneath - which is what happens, but is not how I remember it. NI-S 2001/10/16 */ - int fd = PerlIO_fileno(o); - if (fd >= 0) { - char buf[8]; - FILE *stdio = PerlSIO_fdopen(fd, PerlIO_modestr(o, buf)); - if (stdio) { - if ((f = PerlIOBase_dup(aTHX_ f, o, param))) { - PerlIOSelf(f, PerlIOStdio)->stdio = stdio; - PerlIOUnix_refcnt_inc(fd); - } - else { - PerlSIO_fclose(stdio); - } - } - else { - PerlLIO_close(fd); - f = NULL; - } + if ((f = PerlIOBase_dup(aTHX_ f, o, param))) { + FILE *stdio = PerlIOSelf(o, PerlIOStdio)->stdio; + PerlIOSelf(f, PerlIOStdio)->stdio = stdio; + PerlIOUnix_refcnt_inc(fileno(stdio)); } return f; }