richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
ac3a84
From a1ab44a859080aebd79355f58e57739ce4225e97 Mon Sep 17 00:00:00 2001
ac3a84
From: Yu Watanabe <watanabe.yu+github@gmail.com>
ac3a84
Date: Fri, 20 Jan 2023 14:54:44 +0900
ac3a84
Subject: [PATCH] test-unit-name: fix fd leak
ac3a84
ac3a84
Fixes an issue reported at https://github.com/systemd/systemd/issues/22576#issuecomment-1396774385.
ac3a84
ac3a84
(cherry picked from commit 36f73b6c67afd9c826e612b751ea8f9249da7985)
ac3a84
ac3a84
Related: #2138081
ac3a84
---
ac3a84
 src/test/test-unit-name.c | 4 +++-
ac3a84
 1 file changed, 3 insertions(+), 1 deletion(-)
ac3a84
ac3a84
diff --git a/src/test/test-unit-name.c b/src/test/test-unit-name.c
ac3a84
index 43fdb15d1c..eec4831b4e 100644
ac3a84
--- a/src/test/test-unit-name.c
ac3a84
+++ b/src/test/test-unit-name.c
ac3a84
@@ -241,11 +241,13 @@ TEST_RET(unit_printf, .sd_booted = true) {
ac3a84
                 *user, *group, *uid, *gid, *home, *shell,
ac3a84
                 *tmp_dir, *var_tmp_dir;
ac3a84
         _cleanup_(manager_freep) Manager *m = NULL;
ac3a84
+        _cleanup_close_ int fd = -EBADF;
ac3a84
         Unit *u;
ac3a84
         int r;
ac3a84
 
ac3a84
         _cleanup_(unlink_tempfilep) char filename[] = "/tmp/test-unit_printf.XXXXXX";
ac3a84
-        assert_se(mkostemp_safe(filename) >= 0);
ac3a84
+        fd = mkostemp_safe(filename);
ac3a84
+        assert_se(fd >= 0);
ac3a84
 
ac3a84
         /* Using the specifier functions is admittedly a bit circular, but we don't want to reimplement the
ac3a84
          * logic a second time. We're at least testing that the hookup works. */