: Fix memory leak by freeing buf
PATCH 1/1 : Fix memory leak by freeing buf
From: Manjeet Pawar <[email protected]>
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 <[email protected]>
Signed-off-by Manjeet Pawar <[email protected]>
--- pan/ltp-pan.c | 1 + 1 file changed, 1 insertion(+)
pan/ltp-pan.c +1 -0
@@ -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' ;
Signature · 8 lines
1.7.9.5 ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
Looking at the code, ltp-pan exits if this function fails, so the danger of memory leak was not real here.
But it's better to fix the function, pushed, thanks.
Signature · 8 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list