PR47296 Segfault when running out of file descriptors
authorJanne Blomqvist <jb@gcc.gnu.org>
Mon, 17 Jan 2011 05:48:10 +0000 (07:48 +0200)
committerJanne Blomqvist <jb@gcc.gnu.org>
Mon, 17 Jan 2011 05:48:10 +0000 (07:48 +0200)
From-SVN: r168888

libgfortran/ChangeLog
libgfortran/io/unix.c

index 1eeeda3b5282dbf48811d778767c64b0204d2dc4..cab2d1501e0ab5a62aa3a04792202e25c5755174 100644 (file)
@@ -1,3 +1,9 @@
+2011-01-17  Janne Blomqvist  <jb@gcc.gnu.org>
+
+       PR libfortran/47296
+       * io/unix.c (tempfile): Set opp->file and opp->file_len also if an
+       error occurs.
+
 2011-01-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR fortran/46625
index e66560f5839b1c5ea75c9209b0cd74836e193a6b..fa64e20b02662b2f28284059d659cb576bbad0f6 100644 (file)
@@ -1,4 +1,5 @@
-/* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+/* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+   2011
    Free Software Foundation, Inc.
    Contributed by Andy Vaught
    F2003 I/O support contributed by Jerry DeLisle
@@ -1084,13 +1085,8 @@ tempfile (st_parameter_open *opp)
   while (fd == -1 && errno == EEXIST);
 #endif /* HAVE_MKSTEMP */
 
-  if (fd < 0)
-    free (template);
-  else
-    {
-      opp->file = template;
-      opp->file_len = strlen (template);       /* Don't include trailing nul */
-    }
+  opp->file = template;
+  opp->file_len = strlen (template);   /* Don't include trailing nul */
 
   return fd;
 }