mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 05:18:00 +00:00
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: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
e767c69b30
commit
34f16a4607
14
lib/c/criu.c
14
lib/c/criu.c
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user