From 9f595873077754431dfaa925b7d8d176c5dbe7c4 Mon Sep 17 00:00:00 2001 From: i-ky Date: Tue, 22 Feb 2022 16:02:45 +0000 Subject: [PATCH] Fix a couple of memory leaks in case of `zbx_module_docker_inspect_exec()` failure --- src/modules/zabbix_module_docker/zabbix_module_docker.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/zabbix_module_docker/zabbix_module_docker.c b/src/modules/zabbix_module_docker/zabbix_module_docker.c index 5834a6b..3e455be 100644 --- a/src/modules/zabbix_module_docker/zabbix_module_docker.c +++ b/src/modules/zabbix_module_docker/zabbix_module_docker.c @@ -543,6 +543,7 @@ int zbx_module_docker_port_discovery(AGENT_REQUEST * request, AGENT_RESULT * res iresult = zbx_module_docker_inspect_exec(container, "HostConfig", "PortBindings", NULL); if (iresult.return_code == SYSINFO_RET_FAIL) { zabbix_log(LOG_LEVEL_DEBUG, "zbx_module_docker_inspect_exec FAIL: %s", iresult.value); + free(iresult.value); return SYSINFO_RET_FAIL; } @@ -1776,6 +1777,7 @@ int zbx_module_docker_discovery_extended(AGENT_REQUEST *request, AGENT_RESUL json_object_set_new(o, "{#HCONTAINERID}", json_string(names)); } else { zabbix_log(LOG_LEVEL_DEBUG, "Default HCONTAINERID is used, because zbx_module_docker_inspect_exec FAIL: %s", iresult.value); + free(iresult.value); json_object_set_new(o, "{#HCONTAINERID}", json_string(names)); } } else {