]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
libcgroup: Fixed dereferencing of uninitialized variable when modifying a group
authorJan Safranek <jsafrane@redhat.com>
Wed, 24 Aug 2011 09:46:20 +0000 (11:46 +0200)
committerJan Safranek <jsafrane@redhat.com>
Mon, 19 Sep 2011 11:27:38 +0000 (13:27 +0200)
When group->index == 0, uninitialized variable path might get freed. Path is
always freed in the loop, so it is useless to free it before return.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
src/api.c

index 207d076c81de239866a940317c8d81446a40f857..d68a4c8117e8a574d21b8fd31357607e83a91001 100644 (file)
--- a/src/api.c
+++ b/src/api.c
@@ -1350,7 +1350,7 @@ int cgroup_modify_cgroup(struct cgroup *cgroup)
 {
        char *path, base[FILENAME_MAX];
        int i;
-       int error;
+       int error = 0;
        int ret;
 
        if (!cgroup_initialized)
@@ -1388,12 +1388,7 @@ int cgroup_modify_cgroup(struct cgroup *cgroup)
                                goto err;
                }
        }
-       if (path)
-               free(path);
-       return 0;
 err:
-       if (path)
-               free(path);
        return error;
 
 }