iSulad/0173-bugfix-mem-leak.patch
Lu Jingxiao a1efa78546 Sync patches from upstream for refactoring sandbox and bugfixing
including:
15dd7690 add layer storage ut test
7a3d70db bugfix for parse_http_header
3144357f bugfix: mem leak
02a8be62 image store:fix code style
4f030e07 registry module code improve
0340a824 fix some bad code
7dfa6916 add image storage unit test
1e9031cc UT: del shim_sandbox and change sandbox ops
16da6634 sandbox: del shim_sandbox and change sandbox ops

Signed-off-by: Lu Jingxiao <lujingxiao@huawei.com>
(cherry picked from commit cd18a717e414326116ccbd19bc87e29fa9c4ffc6)
2025-01-06 10:43:52 +08:00

65 lines
2.5 KiB
Diff

From 3144357f7c735e24af180b9352378618ce8b2368 Mon Sep 17 00:00:00 2001
From: liuxu <liuxu156@huawei.com>
Date: Wed, 11 Dec 2024 11:32:06 +0800
Subject: [PATCH 07/11] bugfix: mem leak
Signed-off-by: liuxu <liuxu156@huawei.com>
---
src/daemon/executor/container_cb/execution_network.c | 2 ++
src/daemon/modules/service/inspect_container.c | 2 ++
src/utils/cutils/utils.c | 9 ++++++++-
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/daemon/executor/container_cb/execution_network.c b/src/daemon/executor/container_cb/execution_network.c
index a145e33a..8e34998c 100644
--- a/src/daemon/executor/container_cb/execution_network.c
+++ b/src/daemon/executor/container_cb/execution_network.c
@@ -1213,6 +1213,8 @@ static int generate_network_element(const char **bridges, const size_t len, defs
defs_map_string_object_networks_element *), len);
if (networks->values == NULL) {
ERROR("Out of memory ");
+ free(networks->keys);
+ networks->keys = NULL;
return -1;
}
diff --git a/src/daemon/modules/service/inspect_container.c b/src/daemon/modules/service/inspect_container.c
index 40cf7aa1..ca3955c6 100644
--- a/src/daemon/modules/service/inspect_container.c
+++ b/src/daemon/modules/service/inspect_container.c
@@ -629,6 +629,8 @@ static int do_transform_cni_to_map(container_network_settings *settings)
util_smart_calloc_s(sizeof(defs_map_string_object_port_bindings_element *), settings->cni_ports_len);
if (result->values == NULL) {
ERROR("Out of memory");
+ free(result->keys);
+ result->keys = NULL;
ret = -1;
goto out;
}
diff --git a/src/utils/cutils/utils.c b/src/utils/cutils/utils.c
index 69f6dbf0..cf207acc 100644
--- a/src/utils/cutils/utils.c
+++ b/src/utils/cutils/utils.c
@@ -1609,10 +1609,17 @@ defs_map_string_object *dup_map_string_empty_object(defs_map_string_object *src)
}
dst->keys = util_smart_calloc_s(sizeof(char *), src->len);
+ if (dst->keys == NULL) {
+ ERROR("Out of memory");
+ ret = -1;
+ goto out;
+ }
dst->values = util_smart_calloc_s(sizeof(defs_map_string_object_element *), src->len);
- if (dst->keys == NULL || dst->values == NULL) {
+ if (dst->values == NULL) {
ERROR("Out of memory");
ret = -1;
+ free(dst->keys);
+ dst->keys = NULL;
goto out;
}
--
2.23.0