]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
Add free() call for error handling.
authorKen'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
Tue, 31 Mar 2009 02:05:26 +0000 (11:05 +0900)
committerDhaval Giani <dhaval@linux.vnet.ibm.com>
Tue, 31 Mar 2009 06:03:10 +0000 (11:33 +0530)
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.

Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
src/api.c

index d31cf4d544059cdfeca4afba0c30444db193699d..2d57351fcba38286c89ec51b7c43c9924e159769 100644 (file)
--- a/src/api.c
+++ b/src/api.c
@@ -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;