summaryrefslogtreecommitdiff
path: root/lib/libc/gen
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1996-11-27 22:00:46 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1996-11-27 22:00:46 +0000
commit8730a7ccff4c5ed419045f57690fb82fd2c9fc85 (patch)
treefaf830de3fd6ed369b071bffacf8ff77a5bb87ca /lib/libc/gen
parent1dad1624ba7e422be25efc3e4786b134b01353b0 (diff)
Fix file descriptor leak on error. Noticed by bitblt.
Diffstat (limited to 'lib/libc/gen')
-rw-r--r--lib/libc/gen/getcwd.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/gen/getcwd.c b/lib/libc/gen/getcwd.c
index 1ef4183f97d..19f811a2fc3 100644
--- a/lib/libc/gen/getcwd.c
+++ b/lib/libc/gen/getcwd.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: getcwd.c,v 1.2 1996/08/19 08:23:15 tholo Exp $";
+static char rcsid[] = "$OpenBSD: getcwd.c,v 1.3 1996/11/27 22:00:45 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -55,7 +55,7 @@ getcwd(pt, size)
size_t size;
{
register struct dirent *dp;
- register DIR *dir;
+ register DIR *dir = NULL;
register dev_t dev;
register ino_t ino;
register int first;
@@ -226,5 +226,7 @@ err:
if (ptsize)
free(pt);
free(up);
+ if (dir)
+ (void)closedir(dir);
return (NULL);
}