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

Yousong Zhou yszhou4tech at gmail.com
Mon Mar 20 04:39:48 PDT 2017


Signed-off-by: Yousong Zhou <yszhou4tech at gmail.com>
---
 libbb/xreadlink.c | 1 +
 1 file changed, 1 insertion(+)

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;
 		}
 	}
-- 
2.6.4




More information about the Lede-dev mailing list