summaryrefslogtreecommitdiff
path: root/src/test/test-unit-name.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-01-20 14:54:44 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-01-20 14:55:46 +0900
commit36f73b6c67afd9c826e612b751ea8f9249da7985 (patch)
tree102180ea2e594ebf21c2bb9ca2d7f8b88aee97eb /src/test/test-unit-name.c
parent86d82cb8885afaac374225b945b2efc2a013cb7e (diff)
downloadsystemd-36f73b6c67afd9c826e612b751ea8f9249da7985.tar.gz
test-unit-name: fix fd leak
Fixes an issue reported at https://github.com/systemd/systemd/issues/22576#issuecomment-1396774385.
Diffstat (limited to 'src/test/test-unit-name.c')
-rw-r--r--src/test/test-unit-name.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/test/test-unit-name.c b/src/test/test-unit-name.c
index c6428e844f..3904126a87 100644
--- a/src/test/test-unit-name.c
+++ b/src/test/test-unit-name.c
@@ -242,11 +242,13 @@ TEST_RET(unit_printf, .sd_booted = true) {
*user, *group, *uid, *gid, *home, *shell,
*tmp_dir, *var_tmp_dir;
_cleanup_(manager_freep) Manager *m = NULL;
+ _cleanup_close_ int fd = -EBADF;
Unit *u;
int r;
_cleanup_(unlink_tempfilep) char filename[] = "/tmp/test-unit_printf.XXXXXX";
- assert_se(mkostemp_safe(filename) >= 0);
+ fd = mkostemp_safe(filename);
+ assert_se(fd >= 0);
/* Using the specifier functions is admittedly a bit circular, but we don't want to reimplement the
* logic a second time. We're at least testing that the hookup works. */