Hi,

Ken'ichi Ohmichi wrote:
> I reviewed the libcgroup code in the viewpoint of memory-leak and
> found a lack of free(). This patch adds a free() call for error
> handling.
> 
> 
> Thanks
> Ken'ichi Ohmichi
> 
> Signed-off-by: Ken'ichi Ohmichi <[email protected]>
> ---
> --- a/api.c   2009-03-30 12:14:42.000000000 +0900
> +++ b/api.c   2009-03-30 12:15:13.000000000 +0900
> @@ -589,8 +589,8 @@ int cgroup_init()
>               ret = ECGOTHER;
>               goto unlock_exit;
>       }
> -     buf = fgets(buf, FILENAME_MAX, proc_cgroup);
> -     if (!buf) {
> +     if (!fgets(buf, FILENAME_MAX, proc_cgroup)) {
> +             free(buf);
>               ret = EIO;
>               goto unlock_exit;
>       }

The above patch was based on old libcgroup code, and I created a new
patch based on the latest libcgroup which is taken from git tree.


Thanks
Ken'ichi Ohmichi

Signed-off-by: Ken'ichi Ohmichi <[email protected]>
---
--- a/src/api.c 2009-03-30 19:24:42.000000000 +0900
+++ b/src/api.c 2009-03-31 11:25:06.000000000 +0900
@@ -590,8 +590,8 @@ int cgroup_init()
                ret = ECGOTHER;
                goto unlock_exit;
        }
-       buf = fgets(buf, FILENAME_MAX, proc_cgroup);
-       if (!buf) {
+       if (!fgets(buf, FILENAME_MAX, proc_cgroup)) {
+               free(buf);
                last_errno = errno;
                ret = ECGOTHER;
                goto unlock_exit;

------------------------------------------------------------------------------
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to