[CRIU] [PATCH 09/18] lib/criu: fix a memory leak

Andrei Vagin avagin at openvz.org
Thu Nov 9 22:21:03 MSK 2017


From: Andrei Vagin <avagin at virtuozzo.com>

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 at virtuozzo.com>
---
 lib/c/criu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/c/criu.c b/lib/c/criu.c
index 08806c6ea..3292fccf9 100644
--- a/lib/c/criu.c
+++ b/lib/c/criu.c
@@ -778,13 +778,13 @@ int criu_local_add_cg_dump_controller(criu_opts *opts, char *name)
 	new = realloc(opts->rpc->cgroup_dump_controller, nr * sizeof(char *));
 	if (!new)
 		return -ENOMEM;
+	opts->rpc->cgroup_dump_controller = new;
 
 	new[opts->rpc->n_cgroup_dump_controller] = strdup(name);
 	if (!new[opts->rpc->n_cgroup_dump_controller])
 		return -ENOMEM;
 
 	opts->rpc->n_cgroup_dump_controller = nr;
-	opts->rpc->cgroup_dump_controller = new;
 
 	return 0;
 }
-- 
2.13.6



More information about the CRIU mailing list