diff options
author | mckay <mckay@FreeBSD.org> | 1998-01-15 13:52:55 +0000 |
---|---|---|
committer | mckay <mckay@FreeBSD.org> | 1998-01-15 13:52:55 +0000 |
commit | 46ca486c3c21327f96b98da48c5055699c866df1 (patch) | |
tree | 803b5aa5ade134be5801058c12aca9119de27993 /lib/libc | |
parent | cb201a4a429b174bc5a167c81a652875386775ec (diff) | |
download | FreeBSD-src-46ca486c3c21327f96b98da48c5055699c866df1.zip FreeBSD-src-46ca486c3c21327f96b98da48c5055699c866df1.tar.gz |
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.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gen/getcwd.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/libc/gen/getcwd.c b/lib/libc/gen/getcwd.c index 344a418..f178784 100644 --- a/lib/libc/gen/getcwd.c +++ b/lib/libc/gen/getcwd.c @@ -268,10 +268,14 @@ notfound: 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); } |