From de5d8b40eda84cfd546c9d969a191ce4615e6375 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 23 Jan 2023 15:50:36 +0100 Subject: [PATCH] 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. --- src/sleep/sleep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.47.3