From: Yu Watanabe Date: Sun, 26 Jan 2025 19:17:27 +0000 (+0900) Subject: systemctl: fix memleak X-Git-Tag: v258-rc1~1480 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=08570f284140752b9f0aad4dbcdff32c090a3661;p=thirdparty%2Fsystemd.git systemctl: fix memleak Fixes a bug introduced by adb6cd9be2b7e9e614d2b5835c7b70cf8eacc852. Fixes #36178. --- diff --git a/src/systemctl/systemctl-is-system-running.c b/src/systemctl/systemctl-is-system-running.c index 59be6a7a7ec..8d5303c2d83 100644 --- a/src/systemctl/systemctl-is-system-running.c +++ b/src/systemctl/systemctl-is-system-running.c @@ -66,6 +66,10 @@ int verb_is_system_running(int argc, char *argv[], void *userdata) { } if (arg_wait && STR_IN_SET(state, "initializing", "starting")) { + /* The signal handler will allocate memory and assign to 'state', hence need to free previous + * one before entering the event loop. */ + state = mfree(state); + r = sd_event_loop(event); if (r < 0) { log_warning_errno(r, "Failed to get property from event loop: %m"); @@ -73,6 +77,8 @@ int verb_is_system_running(int argc, char *argv[], void *userdata) { puts("unknown"); return EXIT_FAILURE; } + + assert(state); } if (!arg_quiet)