summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2007-03-19 15:17:27 +0000
committerNicholas Clark <nick@ccl4.org>2007-03-19 15:17:27 +0000
commit6b54a40376f816c07bf5262ecec28e130b304cb8 (patch)
treedb4f6b32ef59c708801d7a22240149808cbd9eb5 /perlio.c
parent5d05e4606eee124eec06ad140a831c75fca95783 (diff)
downloadperl-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.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/perlio.c b/perlio.c
index bba198c102..ef07055ef8 100644
--- a/perlio.c
+++ b/perlio.c
@@ -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;
}