diff --git a/src/core/unit.c b/src/core/unit.c index a12d24b90b..1bbe5fdded 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -571,8 +571,7 @@ void unit_free(Unit *u) { if (!u) return; - if (u->transient_file) - fclose(u->transient_file); + u->transient_file = safe_fclose(u->transient_file); if (!MANAGER_IS_RELOADING(u->manager)) unit_remove_transient(u); @@ -1505,9 +1504,7 @@ int unit_load(Unit *u) { if (r < 0) goto fail; - fclose(u->transient_file); - u->transient_file = NULL; - + u->transient_file = safe_fclose(u->transient_file); u->fragment_mtime = now(CLOCK_REALTIME); }