* Jan Safranek <[email protected]> [2010-06-07 11:58:19]:

> 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) {

Hmm.. I can't find what you mentioned in the man-pages, but your
changelog is correct. I think we should also check for if (line) prior
to freeing line

-- 
        Three Cheers,
        Balbir

------------------------------------------------------------------------------
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