From 302c10c4be1600e391b7573e869bf38fc471920b Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Stelmach?= Date: Tue, 21 Jun 2022 12:12:01 +0200 Subject: [PATCH] core: Fix memory leaks MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit arg_early_core_pattern and arg_watchdog_device hold pointers to memory allocated with strdup() (inside path_make_absolute_cwd). The memory needs to be freed in reset_arguments() during reload rather than forgotten. Change-Id: I2ab2fb856ce9dae70443430d99279f4d4848231e Signed-off-by: Łukasz Stelmach Origin: https://github.com/systemd/systemd/commit/919ea64f69f710840c1bc93f0f7cb7c51aae45d0 --- src/core/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/main.c b/src/core/main.c index a3ccae9..7f9f568 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -2125,8 +2125,8 @@ static void reset_arguments(void) { arg_runtime_watchdog = 0; arg_reboot_watchdog = 0; /* 10 * USEC_PER_MINUTE; */ arg_kexec_watchdog = 0; - arg_early_core_pattern = NULL; - arg_watchdog_device = NULL; + arg_early_core_pattern = mfree(arg_early_core_pattern); + arg_watchdog_device = mfree(arg_watchdog_device); arg_default_environment = strv_free(arg_default_environment); rlimit_free_all(arg_default_rlimit); -- 2.7.4