[LTP] [PATCH]: Fix memory leak by freeing buf

Manjeet Pawar
2015-05-28T04:44:59Z

From: Manjeet Pawar <manjeet.p@samsung.com>
Subject: [PATCH] pan/ltp-pan.c: free buf before function return to avoid memory leak

This patch avoid memory leak by freeing the buf before the slurp() function return

Signed-off-by: Yogesh Gaur <yn.gaur@samsung.com>
Signed-off-by: Manjeet Pawar <manjeet.p@samsung.com>
---
pan/ltp-pan.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/pan/ltp-pan.c b/pan/ltp-pan.c
index 4c1e9de..905ff89 100644
--- a/pan/ltp-pan.c
+++ b/pan/ltp-pan.c
@@ -1279,6 +1279,7 @@ static char *slurp(char *file)
if (read(fd, buf, sbuf.st_size) != sbuf.st_size) {
fprintf(stderr, "pan(%s): slurp failed. errno:%d %s\n",
panname, errno, strerror(errno));
+ free(buf);
return NULL;
}
buf[sbuf.st_size] = '\0';
--
1.7.9.5