diff options
author | Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2011-02-26 15:21:45 +0000 |
---|---|---|
committer | François-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2011-02-26 15:21:45 +0000 |
commit | fe230fccd4ba1cea6c1962a5a533804e05b2ab04 (patch) | |
tree | e1638be58d4956eae30b2f1dcd9ba8c13ccc10ee /libgfortran/io | |
parent | 39113df12c87dd242b397fa9ba862bab673fad4b (diff) | |
download | gcc-fe230fccd4ba1cea6c1962a5a533804e05b2ab04.zip gcc-fe230fccd4ba1cea6c1962a5a533804e05b2ab04.tar.gz gcc-fe230fccd4ba1cea6c1962a5a533804e05b2ab04.tar.bz2 |
re PR libfortran/45165 (unix.c:fallback_access() leaks file descriptors)
PR libfortran/45165
* unix.c (fallback_access): Fix file descriptor leaks.
From-SVN: r170517
Diffstat (limited to 'libgfortran/io')
-rw-r--r-- | libgfortran/io/unix.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c index 004e860..12536ca 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) { |