[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc-fortran
Subject: =?windows-1252?Q?=5Blibgfortran=2C_patch=5D_Fix_fd_leak_in_unix?= =?windows-1252?Q?=2Ec=92s_fallback
From: FX <fxcoudert () gmail ! com>
Date: 2011-02-26 15:11:45
Message-ID: 6405C1A4-782C-41E9-A16D-5685CE93DA61 () gmail ! com
[Download RAW message or body]
The attached patch fixes a file descriptor leak in fallback_access(), a fun=
ction in io/unix.c for systems without a system access() (which happens on =
newlib systems); this is PR 45165.
The patch was tested by building and regtesting on x86_64-darwin, simulatin=
g the lack of access() by overriding libgfortran configure results. OK to c=
ommit to trunk?
Cheers,
FX
PS: I don't think it's worth backporting, as it's only a leak on newlib sys=
tems
["fd_leak.ChangeLog" (fd_leak.ChangeLog)]
2011-02-26 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR libfortran/45165
* unix.c (fallback_access): Fix file descriptor leaks.
["fd_leak.diff" (fd_leak.diff)]
Index: unix.c
===================================================================
--- unix.c (revision 170501)
+++ unix.c (working copy)
@@ -144,11 +144,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)
{
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic