From: Graham Barr Date: Mon, 13 Jan 1997 02:07:59 +0000 (+1200) Subject: Fix for fd leak in IO::File::new_tmpfile X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a375a877d6d52b8fe1c40e6f3e1bdeb7b23aaa67;p=p5sagit%2Fp5-mst-13.2.git Fix for fd leak in IO::File::new_tmpfile Signed-off-by: Graham Barr --- diff --git a/ext/IO/IO.xs b/ext/IO/IO.xs index a6eb075..daa22f6 100644 --- a/ext/IO/IO.xs +++ b/ext/IO/IO.xs @@ -121,17 +121,28 @@ fsetpos(handle, pos) MODULE = IO PACKAGE = IO::File PREFIX = f -OutputStream +SV * new_tmpfile(packname = "IO::File") char * packname + PREINIT: + OutputStream fp; + GV *gv; CODE: #ifdef PerlIO - RETVAL = PerlIO_tmpfile(); + fp = PerlIO_tmpfile(); #else - RETVAL = tmpfile(); + fp = tmpfile(); #endif - OUTPUT: - RETVAL + gv = (GV*)SvREFCNT_inc(newGVgen(packname)); + hv_delete(GvSTASH(gv), GvNAME(gv), GvNAMELEN(gv), G_DISCARD); + if (do_open(gv, "+>&", 3, FALSE, 0, 0, fp)) { + ST(0) = sv_2mortal(newRV_noinc((SV*)gv)); + sv_bless(ST(0), gv_stashpv(packname, TRUE)); + } + else { + ST(0) = &sv_undef; + SvREFCNT_dec(gv); + } MODULE = IO PACKAGE = IO::Handle PREFIX = f diff --git a/ext/IO/lib/IO/Handle.pm b/ext/IO/lib/IO/Handle.pm index af706cf..e271268 100644 --- a/ext/IO/lib/IO/Handle.pm +++ b/ext/IO/lib/IO/Handle.pm @@ -192,7 +192,7 @@ use SelectSaver; require Exporter; @ISA = qw(Exporter); -$VERSION = "1.14"; +$VERSION = "1.1401"; @EXPORT_OK = qw( autoflush