summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/getcwd.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/gen/getcwd.c')
-rw-r--r--lib/libc/gen/getcwd.c4
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);
}
OpenPOWER on IntegriCloud