Change the non-mkstemp, non-win32 code path of PerlIO_tmpfile
authorCraig A. Berry <craigberry@mac.com>
Mon, 30 Oct 2006 00:23:35 +0000 (00:23 +0000)
committerCraig A. Berry <craigberry@mac.com>
Mon, 30 Oct 2006 00:23:35 +0000 (00:23 +0000)
to use PerlIO_fdopen so that when the tmpfile is closed we do
not decrement a ref count that doesn't exist or is zero.

p4raw-id: //depot/perl@29143

perlio.c

index 06a360b..a5d4377 100644 (file)
--- a/perlio.c
+++ b/perlio.c
@@ -5090,16 +5090,9 @@ PerlIO_tmpfile(void)
 #    else      /* !HAS_MKSTEMP, fallback to stdio tmpfile(). */
      FILE * const stdio = PerlSIO_tmpfile();
 
-     if (stdio) {
-         if ((f = PerlIO_push(aTHX_(PerlIO_allocate(aTHX)),
-                               PERLIO_FUNCS_CAST(&PerlIO_stdio),
-                              "w+", NULL))) {
-              PerlIOStdio * const s = PerlIOSelf(f, PerlIOStdio);
-
-               if (s)
-                    s->stdio = stdio;
-          }
-     }
+     if (stdio)
+         f = PerlIO_fdopen(fileno(stdio), "w+");
+
 #    endif /* else HAS_MKSTEMP */
 #endif /* else WIN32 */
      return f;