libbb: xreadlink: fix memory leak on failure case
authorYousong Zhou <yszhou4tech@gmail.com>
Mon, 20 Mar 2017 02:46:15 +0000 (10:46 +0800)
committerYousong Zhou <yszhou4tech@gmail.com>
Tue, 2 May 2017 14:12:49 +0000 (22:12 +0800)
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
libbb/xreadlink.c

index 596a7638d1bf3aa594907493cb7f878e2ce7d0c1..29949d1ae96fbe06865fc4f4d2ff5df4a5468317 100644 (file)
@@ -25,6 +25,7 @@ extern char *xreadlink(const char *path)
                readsize = readlink(path, buf, bufsize);        /* 1st try */
                if (readsize == -1) {
                        perror_msg("%s", path);
+                       free(buf);
                        return NULL;
                }
        }