diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2011-05-10 20:19:46 +0200 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2011-05-10 20:19:46 +0200 |
commit | e48bd60ce9a70d190acfee7db98c0f163a2c5fdb (patch) | |
tree | 2dd7bf452ea83af5fbe1df1a5b1565946a2e98d2 /libc/sysdeps/linux | |
parent | 025ec197fe9d069c6d705e6f7d1509bb9dc1ce56 (diff) |
getcwd: Fix memory-leak in error path
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libc/sysdeps/linux')
-rw-r--r-- | libc/sysdeps/linux/common/getcwd.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libc/sysdeps/linux/common/getcwd.c b/libc/sysdeps/linux/common/getcwd.c index 75d7a1c8b..87510019e 100644 --- a/libc/sysdeps/linux/common/getcwd.c +++ b/libc/sysdeps/linux/common/getcwd.c @@ -69,7 +69,7 @@ static char *search_dir(dev_t this_dev, ino_t this_ino, char *path_buf, int path slen++; dp = opendir(path_buf); - if (dp == 0) { + if (!dp) { goto oops; } @@ -78,6 +78,7 @@ static char *search_dir(dev_t this_dev, ino_t this_ino, char *path_buf, int path if (slow_search || this_ino == d->d_ino) { # endif if (slen + strlen(d->d_name) > path_size) { + closedir(dp); goto oops; } strcpy(ptr + 1, d->d_name); |