This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix clone_leak problem.
authorNick Ing-Simmons <nik@tiuk.ti.com>
Sat, 3 Nov 2001 10:27:34 +0000 (10:27 +0000)
committerNick Ing-Simmons <nik@tiuk.ti.com>
Sat, 3 Nov 2001 10:27:34 +0000 (10:27 +0000)
PerlIOStdio_dup was leaking FILE * as it was still doing fdopen()
as vestige of calling PerlLIO_dup().

p4raw-id: //depot/perlio@12830

perlio.c

index f08ba48..c960a03 100644 (file)
--- 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;
 }