]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
libcgroup: Fix up some free errors
authorDhaval Giani <dhaval@linux.vnet.ibm.com>
Thu, 14 Aug 2008 14:29:29 +0000 (14:29 +0000)
committerDhaval Giani <dhaval@linux.vnet.ibm.com>
Thu, 14 Aug 2008 14:29:29 +0000 (14:29 +0000)
Sudhir reported a free() issue, it got traced to this issue.

https://sourceforge.net/tracker/index.php?func=detail&aid=2049822&group_id=218421&atid=1043649

Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Cc: Sudhir Kumar <skumar@linux.vnet.ibm.com>
Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@150 4f4bb910-9a46-0410-90c8-c897d4f1cd53

api.c

diff --git a/api.c b/api.c
index 5b95466e5725cb3f63dff8c9d73bb9d284e51942..e0a7b1185420f8bb62f7ad0811a4afcc2397c59a 100644 (file)
--- a/api.c
+++ b/api.c
@@ -795,11 +795,10 @@ static int cgroup_fill_cgc(struct dirent *ctrl_dir, struct cgroup *cgroup,
                if (cgroup_add_value_string(cgc, ctrl_dir->d_name,
                                ctrl_value)) {
                        error = ECGFAIL;
-                       goto fill_error;
                }
+               free(ctrl_value);
        }
 fill_error:
-       free(ctrl_value);
        free(d_name);
        return error;
 }
@@ -861,7 +860,8 @@ struct cgroup *cgroup_get_cgroup(struct cgroup *cgroup)
                 * Get the uid and gid information
                 */
 
-               control_path = strdup(path);
+               control_path = malloc(strlen(path)+strlen("tasks") + 1);
+               strcpy(control_path, path);
 
                if (!control_path)
                        goto unlock_error;