]> git.proxmox.com Git - lxc.git/blob - debian/patches/fixes/0003-Fix-memory-leak-in-list_active_containers.patch
bump version to 3.0.0-3
[lxc.git] / debian / patches / fixes / 0003-Fix-memory-leak-in-list_active_containers.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: LiFeng <lifeng68@huawei.com>
3 Date: Tue, 24 Apr 2018 15:10:15 -0400
4 Subject: [PATCH] Fix memory leak in list_active_containers
5
6 Signed-off-by: LiFeng <lifeng68@huawei.com>
7 ---
8 src/lxc/lxccontainer.c | 25 +++++++++++++++++++++----
9 1 file changed, 21 insertions(+), 4 deletions(-)
10
11 diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
12 index 6d41b6cf..6a58d81c 100644
13 --- a/src/lxc/lxccontainer.c
14 +++ b/src/lxc/lxccontainer.c
15 @@ -4973,32 +4973,49 @@ int list_active_containers(const char *lxcpath, char ***nret,
16 char *recvpath = lxc_cmd_get_lxcpath(p);
17 if (!recvpath)
18 continue;
19 - if (strncmp(lxcpath, recvpath, lxcpath_len) != 0)
20 + if (strncmp(lxcpath, recvpath, lxcpath_len) != 0) {
21 + free(recvpath);
22 continue;
23 + }
24 + free(recvpath);
25 p = lxc_cmd_get_name(p);
26 if (!p)
27 continue;
28 }
29
30 - if (array_contains(&ct_name, p, ct_name_cnt))
31 + if (array_contains(&ct_name, p, ct_name_cnt)) {
32 + if (is_hashed)
33 + free(p);
34 continue;
35 + }
36
37 - if (!add_to_array(&ct_name, p, ct_name_cnt))
38 + if (!add_to_array(&ct_name, p, ct_name_cnt)) {
39 + if (is_hashed)
40 + free(p);
41 goto free_cret_list;
42 + }
43
44 ct_name_cnt++;
45
46 - if (!cret)
47 + if (!cret) {
48 + if (is_hashed)
49 + free(p);
50 continue;
51 + }
52
53 c = lxc_container_new(p, lxcpath);
54 if (!c) {
55 INFO("Container %s:%s is running but could not be loaded",
56 lxcpath, p);
57 remove_from_array(&ct_name, p, ct_name_cnt--);
58 + if (is_hashed)
59 + free(p);
60 continue;
61 }
62
63 + if (is_hashed)
64 + free(p);
65 +
66 /*
67 * If this is an anonymous container, then is_defined *can*
68 * return false. So we don't do that check. Count on the
69 --
70 2.11.0
71