aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbb/xreadlink.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/libbb/xreadlink.c b/libbb/xreadlink.c
index a5f7eb8be..0b6eb05f3 100644
--- a/libbb/xreadlink.c
+++ b/libbb/xreadlink.c
@@ -8,7 +8,7 @@
8 8
9/* 9/*
10 * NOTE: This function returns a malloced char* that you will have to free 10 * NOTE: This function returns a malloced char* that you will have to free
11 * yourself. You have been warned. 11 * yourself.
12 */ 12 */
13char *xmalloc_readlink(const char *path) 13char *xmalloc_readlink(const char *path)
14{ 14{
@@ -33,14 +33,14 @@ char *xmalloc_readlink(const char *path)
33} 33}
34 34
35/* 35/*
36 * this routine is not the same as realpath(), which 36 * This routine is not the same as realpath(), which
37 * canonicalizes the given path completely. this routine only 37 * canonicalizes the given path completely. This routine only
38 * follows trailing symlinks until a real file is reached, and 38 * follows trailing symlinks until a real file is reached and
39 * returns its name. if the path ends in a dangling link, or if 39 * returns its name. If the path ends in a dangling link or if
40 * the target doesn't exist, the path is returned in any case. 40 * the target doesn't exist, the path is returned in any case.
41 * intermediate symlinks in the path are not expanded -- only 41 * Intermediate symlinks in the path are not expanded -- only
42 * those at the tail. 42 * those at the tail.
43 * a malloced char* is returned, which must be freed by the caller. 43 * A malloced char* is returned, which must be freed by the caller.
44 */ 44 */
45char *xmalloc_follow_symlinks(const char *path) 45char *xmalloc_follow_symlinks(const char *path)
46{ 46{
@@ -60,12 +60,12 @@ char *xmalloc_follow_symlinks(const char *path)
60 /* not a symlink, or doesn't exist */ 60 /* not a symlink, or doesn't exist */
61 if (errno == EINVAL || errno == ENOENT) 61 if (errno == EINVAL || errno == ENOENT)
62 return buf; 62 return buf;
63 free(buf); 63 goto free_buf_ret_null;
64 return NULL; 64 }
65 }
66 65
67 if (!--looping) { 66 if (!--looping) {
68 free(linkpath); 67 free(linkpath);
68free_buf_ret_null:
69 free(buf); 69 free(buf);
70 return NULL; 70 return NULL;
71 } 71 }