summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libc/gen/getcwd.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/libc/gen/getcwd.c b/lib/libc/gen/getcwd.c
index a58988032be..5b9d5c6a609 100644
--- a/lib/libc/gen/getcwd.c
+++ b/lib/libc/gen/getcwd.c
@@ -28,7 +28,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: getcwd.c,v 1.12 2005/03/25 15:38:47 otto Exp $";
+static char rcsid[] = "$OpenBSD: getcwd.c,v 1.13 2005/06/01 18:55:59 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -221,10 +221,15 @@ notfound:
errno = save_errno ? save_errno : ENOENT;
/* FALLTHROUGH */
err:
+ save_errno = errno;
+
if (ptsize)
free(pt);
free(up);
if (dir)
(void)closedir(dir);
+
+ errno = save_errno;
+
return (NULL);
}