[LEDE-DEV,opkg-lede,1/2] libbb: xreadlink: fix memory leak on failure case

Message ID 1490009989-29321-1-git-send-email-yszhou4tech@gmail.com
State Accepted
Delegated to: Jo-Philipp Wich
Headers show

Commit Message

Yousong Zhou March 20, 2017, 11:39 a.m.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
---
 libbb/xreadlink.c | 1 +
 1 file changed, 1 insertion(+)

Patch

diff --git a/libbb/xreadlink.c b/libbb/xreadlink.c
index 596a763..29949d1 100644
--- a/libbb/xreadlink.c
+++ b/libbb/xreadlink.c
@@ -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;
 		}
 	}