[PATCH 2/2] stat: don't leak linkname
Alexander Shishkin
virtuoso at slind.org
Wed Oct 20 20:58:06 UTC 2010
Signed-off-by: Alexander Shishkin <virtuoso at slind.org>
---
coreutils/stat.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/coreutils/stat.c b/coreutils/stat.c
index 7771972..aec5deb 100644
--- a/coreutils/stat.c
+++ b/coreutils/stat.c
@@ -601,9 +601,10 @@ static bool do_stat(const char *filename, const char *format)
if (S_ISLNK(statbuf.st_mode))
linkname = xmalloc_readlink_or_warn(filename);
- if (linkname)
+ if (linkname) {
printf(" File: '%s' -> '%s'\n", filename, linkname);
- else
+ free(linkname);
+ } else
printf(" File: '%s'\n", filename);
printf(" Size: %-10llu\tBlocks: %-10llu IO Block: %-6lu %s\n"
--
1.7.2.1.45.gb66c2
More information about the busybox
mailing list