mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-25 17:16:16 +08:00
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
This commit is contained in:
parent
39113df12c
commit
fe230fccd4
@ -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
|
||||
|
@ -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)
|
||||
return -1;
|
||||
int fd;
|
||||
|
||||
if ((mode & W_OK) && open (path, O_WRONLY) < 0)
|
||||
if ((mode & R_OK) && (fd = open (path, O_RDONLY)) < 0)
|
||||
return -1;
|
||||
close (fd);
|
||||
|
||||
if ((mode & W_OK) && (fd = open (path, O_WRONLY)) < 0)
|
||||
return -1;
|
||||
close (fd);
|
||||
|
||||
if (mode == F_OK)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user