summaryrefslogtreecommitdiffstats
path: root/libgfortran
diff options
context:
space:
mode:
authorfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2011-02-26 15:21:45 +0000
committerfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2011-02-26 15:21:45 +0000
commit398e846bacfb4b1449675d9f1c5517a8f6de1c0d (patch)
treee1638be58d4956eae30b2f1dcd9ba8c13ccc10ee /libgfortran
parenta67d1cefd04e7f051c581742665b4daaf11b0156 (diff)
downloadppe42-gcc-398e846bacfb4b1449675d9f1c5517a8f6de1c0d.tar.gz
ppe42-gcc-398e846bacfb4b1449675d9f1c5517a8f6de1c0d.zip
PR libfortran/45165
* unix.c (fallback_access): Fix file descriptor leaks. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170517 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog5
-rw-r--r--libgfortran/io/unix.c8
2 files changed, 11 insertions, 2 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index dbafd0c9589..bc85a6c9e0f 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,8 @@
+2011-02-26 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
+ PR libfortran/45165
+ * unix.c (fallback_access): Fix file descriptor leaks.
+
2011-02-25 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
* acinclude.m4 (LIBGFOR_CHECK_FPSETMASK): Set shell variable
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index 004e8606c0a..12536ca5cbe 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -144,11 +144,15 @@ typedef struct stat gfstat_t;
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)
{
OpenPOWER on IntegriCloud