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 596a763..29949d1 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;
                }
        }