diff options
Diffstat (limited to 'libgfortran/io/unix.c')
-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) { |