getline(&line, ...) can return -1 *and* allocate memory for returned (empty)
line - so be sure to free it.

Signed-off-by: Jan Safranek <[email protected]>
---

 src/api.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/api.c b/src/api.c
index 4823006..abe8fc4 100644
--- a/src/api.c
+++ b/src/api.c
@@ -2784,8 +2784,10 @@ static int cg_read_stat(FILE *fp, struct cgroup_stat 
*cgroup_stat)
        char *saveptr = NULL;
 
        read_bytes = getline(&line, &len, fp);
-       if (read_bytes == -1)
-               return ECGEOF;
+       if (read_bytes == -1) {
+               ret = ECGEOF;
+               goto out_free;
+       }
 
        token = strtok_r(line, " ", &saveptr);
        if (!token) {


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to