Fix for fd leak in IO::File::new_tmpfile
authorGraham Barr <gbarr@ti.com>
Mon, 13 Jan 1997 02:07:59 +0000 (14:07 +1200)
committerChip Salzenberg <chip@atlantic.net>
Wed, 15 Jan 1997 19:24:00 +0000 (07:24 +1200)
Signed-off-by: Graham Barr <gbarr@ti.com>
ext/IO/IO.xs
ext/IO/lib/IO/Handle.pm

index a6eb075964aee844d4065099168280429c80471f..daa22f600089aabcc67bffeae8cbb71dfe377c0f 100644 (file)
@@ -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
 
index af706cfc690974ec6661b22311ae68eb9c4d11a5..e2712683905eebaf194fd56c4d6d82efc9672237 100644 (file)
@@ -192,7 +192,7 @@ use SelectSaver;
 require Exporter;
 @ISA = qw(Exporter);
 
-$VERSION = "1.14";
+$VERSION = "1.1401";
 
 @EXPORT_OK = qw(
     autoflush