Browse Source

libbb: xreadlink: fix memory leak on failure case

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Yousong Zhou 7 years ago
parent
commit
7a9697267d
1 changed files with 1 additions and 0 deletions
  1. 1 0
      libbb/xreadlink.c

+ 1 - 0
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;
 		}
 	}