diff options
author | Nicholas Clark <nick@ccl4.org> | 2007-03-19 15:17:27 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2007-03-19 15:17:27 +0000 |
commit | 6b54a40376f816c07bf5262ecec28e130b304cb8 (patch) | |
tree | db4f6b32ef59c708801d7a22240149808cbd9eb5 /perlio.c | |
parent | 5d05e4606eee124eec06ad140a831c75fca95783 (diff) | |
download | perl-6b54a40376f816c07bf5262ecec28e130b304cb8.tar.gz |
PerlIO_exportFILE() and PerlIO_releaseFILE() should manage the fd
reference counts correctly.
p4raw-id: //depot/perl@30633
Diffstat (limited to 'perlio.c')
-rw-r--r-- | perlio.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -3552,6 +3552,7 @@ PerlIO_exportFILE(PerlIO * f, const char *mode) if ((f2 = PerlIO_push(aTHX_ f, PERLIO_FUNCS_CAST(&PerlIO_stdio), buf, NULL))) { PerlIOStdio *s = PerlIOSelf((f = f2), PerlIOStdio); s->stdio = stdio; + PerlIOUnix_refcnt_inc(fileno(stdio)); /* Link previous lower layers under new one */ *PerlIONext(f) = l; } @@ -3591,6 +3592,9 @@ PerlIO_releaseFILE(PerlIO *p, FILE *f) PerlIOStdio *s = PerlIOSelf(&l, PerlIOStdio); if (s->stdio == f) { dTHX; + const int fd = fileno(f); + if (fd >= 0) + PerlIOUnix_refcnt_dec(fd); PerlIO_pop(aTHX_ p); return; } |