Return the correct errno from getcwd() even if free() or closedir()

overwrites it.  This actually showed up when running under an old
kernel when free() called the madvise() stub which set errno, causing
getcwd() to return EOPNOTSUPP instead of ERANGE.
This commit is contained in:
Stephen McKay 1998-01-15 13:52:55 +00:00
parent 7cb9d73216
commit 4773010d2f

View File

@ -268,10 +268,14 @@ getcwd(pt, size)
errno = save_errno ? save_errno : ENOENT;
/* FALLTHROUGH */
err:
save_errno = errno;
if (ptsize)
free(pt);
if (dir)
(void) closedir(dir);
free(up);
errno = save_errno;
return (NULL);
}