Commit 5f94389c authored by Andrei Vagin's avatar Andrei Vagin

cgroups: don't leak memory on a error path

CID 161693 (#1 of 1): Resource leak (RESOURCE_LEAK)
5. leaked_storage: Variable new going out of scope leaks the storage it points to.
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 93b53937
......@@ -771,17 +771,21 @@ int criu_local_add_cg_props_file(criu_opts *opts, char *path)
int criu_local_add_cg_dump_controller(criu_opts *opts, char *name)
{
char **new;
char **new, *ctrl_name;
size_t nr;
ctrl_name = strdup(name);
if (!ctrl_name)
return -ENOMEM;
nr = opts->rpc->n_cgroup_dump_controller + 1;
new = realloc(opts->rpc->cgroup_dump_controller, nr * sizeof(char *));
if (!new)
if (!new) {
free(ctrl_name);
return -ENOMEM;
}
new[opts->rpc->n_cgroup_dump_controller] = strdup(name);
if (!new[opts->rpc->n_cgroup_dump_controller])
return -ENOMEM;
new[opts->rpc->n_cgroup_dump_controller] = ctrl_name;
opts->rpc->n_cgroup_dump_controller = nr;
opts->rpc->cgroup_dump_controller = new;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment