summaryrefslogtreecommitdiff
path: root/src/du.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1995-02-23 21:12:11 +0000
committerJim Meyering <jim@meyering.net>1995-02-23 21:12:11 +0000
commitaeebbd038cba80ae8d58fbfccfcdf3fa79782d13 (patch)
tree97e841f11f9d4f9b4b64901746c5bd8ff1e870fc /src/du.c
parent875eafd4895baf158e376508b84832e6c047b6a8 (diff)
downloadcoreutils-aeebbd038cba80ae8d58fbfccfcdf3fa79782d13.tar.xz
(save_cwd) [!HAVE_FCHDIR]: Avoid a core dump via abort() which occurred
because cwd->desc was uninitialed. (restore_cwd) [!HAVE_FCHDIR]: Remove unnecessary redefinition of fchdir. Both from Bruno Haible.
Diffstat (limited to 'src/du.c')
-rw-r--r--src/du.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/src/du.c b/src/du.c
index b23b9acb4..de78b3171 100644
--- a/src/du.c
+++ b/src/du.c
@@ -225,6 +225,7 @@ save_cwd (cwd)
if (!have_working_fchdir)
{
+ cwd->desc = -1;
cwd->name = xgetcwd ();
if (cwd->name == NULL)
error (1, errno, "cannot get current directory");
@@ -241,11 +242,6 @@ restore_cwd (cwd, dest, current)
const char *dest;
const char *current;
{
-
-#ifndef HAVE_FCHDIR
-#define fchdir(x) (abort (), -1)
-#endif
-
if (cwd->desc >= 0)
{
if (fchdir (cwd->desc) < 0)