From: Zbigniew Jędrzejewski-Szmek Date: Mon, 23 Jan 2023 14:50:36 +0000 (+0100) Subject: sleep: fix memleak X-Git-Tag: v253-rc1~21^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F26159%2Fhead;p=thirdparty%2Fsystemd.git sleep: fix memleak Those hashmaps are created anew in each iteration of the loop. The leak wasn't really a problem, because the loop is bounded and the hashmaps were not huge, but it's nicer to be correct. --- diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c index de5b9ae1922..c2c8c779ad8 100644 --- a/src/sleep/sleep.c +++ b/src/sleep/sleep.c @@ -267,12 +267,12 @@ static int execute( } static int custom_timer_suspend(const SleepConfig *sleep_config) { - _cleanup_hashmap_free_ Hashmap *last_capacity = NULL, *current_capacity = NULL; int r; assert(sleep_config); while (battery_is_low() == 0) { + _cleanup_hashmap_free_ Hashmap *last_capacity = NULL, *current_capacity = NULL; _cleanup_close_ int tfd = -EBADF; struct itimerspec ts = {}; usec_t suspend_interval = sleep_config->hibernate_delay_sec, before_timestamp = 0, after_timestamp = 0, total_suspend_interval;