|
|
594167 |
From d35c27e44abcde252abddf369762dee8da309903 Mon Sep 17 00:00:00 2001
|
|
|
594167 |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
594167 |
Date: Tue, 10 May 2022 14:09:24 +0900
|
|
|
594167 |
Subject: [PATCH] core/timer: fix memleak
|
|
|
594167 |
|
|
|
594167 |
Fixes #23326.
|
|
|
594167 |
|
|
|
594167 |
(cherry picked from commit d3ab7b8078944db28bc621f43dd942a3c878fffb)
|
|
|
594167 |
Related: #2087652
|
|
|
594167 |
---
|
|
|
594167 |
src/core/timer.c | 11 ++++++-----
|
|
|
594167 |
1 file changed, 6 insertions(+), 5 deletions(-)
|
|
|
594167 |
|
|
|
594167 |
diff --git a/src/core/timer.c b/src/core/timer.c
|
|
|
594167 |
index a13b864741..0dc49dd46b 100644
|
|
|
594167 |
--- a/src/core/timer.c
|
|
|
594167 |
+++ b/src/core/timer.c
|
|
|
594167 |
@@ -135,6 +135,7 @@ static int timer_add_trigger_dependencies(Timer *t) {
|
|
|
594167 |
}
|
|
|
594167 |
|
|
|
594167 |
static int timer_setup_persistent(Timer *t) {
|
|
|
594167 |
+ _cleanup_free_ char *stamp_path = NULL;
|
|
|
594167 |
int r;
|
|
|
594167 |
|
|
|
594167 |
assert(t);
|
|
|
594167 |
@@ -148,13 +149,13 @@ static int timer_setup_persistent(Timer *t) {
|
|
|
594167 |
if (r < 0)
|
|
|
594167 |
return r;
|
|
|
594167 |
|
|
|
594167 |
- t->stamp_path = strjoin("/var/lib/systemd/timers/stamp-", UNIT(t)->id);
|
|
|
594167 |
+ stamp_path = strjoin("/var/lib/systemd/timers/stamp-", UNIT(t)->id);
|
|
|
594167 |
} else {
|
|
|
594167 |
const char *e;
|
|
|
594167 |
|
|
|
594167 |
e = getenv("XDG_DATA_HOME");
|
|
|
594167 |
if (e)
|
|
|
594167 |
- t->stamp_path = strjoin(e, "/systemd/timers/stamp-", UNIT(t)->id);
|
|
|
594167 |
+ stamp_path = strjoin(e, "/systemd/timers/stamp-", UNIT(t)->id);
|
|
|
594167 |
else {
|
|
|
594167 |
|
|
|
594167 |
_cleanup_free_ char *h = NULL;
|
|
|
594167 |
@@ -163,14 +164,14 @@ static int timer_setup_persistent(Timer *t) {
|
|
|
594167 |
if (r < 0)
|
|
|
594167 |
return log_unit_error_errno(UNIT(t), r, "Failed to determine home directory: %m");
|
|
|
594167 |
|
|
|
594167 |
- t->stamp_path = strjoin(h, "/.local/share/systemd/timers/stamp-", UNIT(t)->id);
|
|
|
594167 |
+ stamp_path = strjoin(h, "/.local/share/systemd/timers/stamp-", UNIT(t)->id);
|
|
|
594167 |
}
|
|
|
594167 |
}
|
|
|
594167 |
|
|
|
594167 |
- if (!t->stamp_path)
|
|
|
594167 |
+ if (!stamp_path)
|
|
|
594167 |
return log_oom();
|
|
|
594167 |
|
|
|
594167 |
- return 0;
|
|
|
594167 |
+ return free_and_replace(t->stamp_path, stamp_path);
|
|
|
594167 |
}
|
|
|
594167 |
|
|
|
594167 |
static uint64_t timer_get_fixed_delay_hash(Timer *t) {
|