diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-11-04 21:11:41 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-11-04 21:11:41 +0000 |
commit | 9378784537d0a4cd4e630aa360d0ae838dfcf500 (patch) | |
tree | e1607d2c9565d13cc916214f1c4c9a603a0202d3 /io/ftw.c | |
parent | 1c15327821aee947476284374a96c7ebb64dc0d6 (diff) | |
download | glibc-9378784537d0a4cd4e630aa360d0ae838dfcf500.zip glibc-9378784537d0a4cd4e630aa360d0ae838dfcf500.tar.gz glibc-9378784537d0a4cd4e630aa360d0ae838dfcf500.tar.bz2 |
Update.
2003-11-04 Jakub Jelinek <jakub@redhat.com>
* io/ftw.c (ftw_dir): Close dir if callback with FTW_D type returns
non-zero.
* io/Makefile (tests): Add bug-ftw4.
* io/bug-ftw4.c: New test.
Diffstat (limited to 'io/ftw.c')
-rw-r--r-- | io/ftw.c | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -476,23 +476,27 @@ ftw_dir (struct ftw_data *data, struct STAT *st) { result = (*data->func) (data->dirbuf, st, FTW_D, &data->ftw); if (result != 0) - return result; - } - - /* If necessary, change to this directory. */ - if (data->flags & FTW_CHDIR) - { - if (__fchdir (dirfd (dir.stream)) < 0) { - int save_err = errno; + int save_err; +fail: + save_err = errno; __closedir (dir.stream); __set_errno (save_err); if (data->actdir-- == 0) data->actdir = data->maxdir - 1; data->dirstreams[data->actdir] = NULL; + return result; + } + } - return -1; + /* If necessary, change to this directory. */ + if (data->flags & FTW_CHDIR) + { + if (__fchdir (dirfd (dir.stream)) < 0) + { + result = -1; + goto fail; } } |