summaryrefslogtreecommitdiff
path: root/lib/fchdir.c
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2009-09-01 10:06:44 -0600
committerEric Blake <ebb9@byu.net>2009-09-01 13:08:38 -0600
commit0a9873c53517b88fe01a2678002b95574e433a03 (patch)
treeaf3094d625118316359a12b5a61992414f1a4f60 /lib/fchdir.c
parent1f6f04fa73397e0ed8de600aafdec45b976335a8 (diff)
downloadgnulib-0a9873c53517b88fe01a2678002b95574e433a03.tar.gz
fchdir: fix off-by-one bug in previous patch
* lib/fchdir.c (rpl_fstat): Use correct bounds. (_gl_unregister_fd): Delete useless if. Signed-off-by: Eric Blake <ebb9@byu.net>
Diffstat (limited to 'lib/fchdir.c')
-rw-r--r--lib/fchdir.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/fchdir.c b/lib/fchdir.c
index cedbcde7fe..170505f157 100644
--- a/lib/fchdir.c
+++ b/lib/fchdir.c
@@ -93,8 +93,7 @@ _gl_unregister_fd (int fd)
{
if (fd >= 0 && fd < dirs_allocated)
{
- if (dirs[fd].name != NULL)
- free (dirs[fd].name);
+ free (dirs[fd].name);
dirs[fd].name = NULL;
dirs[fd].saved_errno = ENOTDIR;
}
@@ -126,7 +125,7 @@ _gl_register_fd (int fd, const char *filename)
int
rpl_fstat (int fd, struct stat *statbuf)
{
- if (0 <= fd && fd <= dirs_allocated && dirs[fd].name != NULL)
+ if (0 <= fd && fd < dirs_allocated && dirs[fd].name != NULL)
return stat (dirs[fd].name, statbuf);
return fstat (fd, statbuf);
}