[Bug libfortran/45165] unix.c:fallback_access() leaks file descriptors

fxcoudert at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Mon Aug 23 08:40:00 GMT 2010



------- Comment #1 from fxcoudert at gcc dot gnu dot org  2010-08-23 08:39 -------
Index: io/unix.c
===================================================================
--- io/unix.c   (revision 163225)
+++ io/unix.c   (working copy)
@@ -151,11 +151,15 @@
 static int
 fallback_access (const char *path, int mode)
 {
-  if ((mode & R_OK) && open (path, O_RDONLY) < 0)
+  int fd;
+
+  if ((mode & R_OK) && (fd = open (path, O_RDONLY)) < 0)
     return -1;
+  close (fd);

-  if ((mode & W_OK) && open (path, O_WRONLY) < 0)
+  if ((mode & W_OK) && (fd = open (path, O_WRONLY)) < 0)
     return -1;
+  close (fd);

   if (mode == F_OK)
     {


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fxcoudert at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-08-23 08:39:57
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45165



More information about the Gcc-bugs mailing list