1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-03 01:17:45 +03:00

test-unit-name: fix fd leak

Fixes an issue reported at https://github.com/systemd/systemd/issues/22576#issuecomment-1396774385.

(cherry picked from commit 36f73b6c67)
(cherry picked from commit 728f083257)
This commit is contained in:
Yu Watanabe 2023-01-20 14:54:44 +09:00 committed by Luca Boccassi
parent e713ab8ea0
commit 96633df462

View File

@ -241,11 +241,13 @@ TEST_RET(unit_printf, .sd_booted = true) {
*user, *group, *uid, *gid, *home, *shell, *user, *group, *uid, *gid, *home, *shell,
*tmp_dir, *var_tmp_dir; *tmp_dir, *var_tmp_dir;
_cleanup_(manager_freep) Manager *m = NULL; _cleanup_(manager_freep) Manager *m = NULL;
_cleanup_close_ int fd = -EBADF;
Unit *u; Unit *u;
int r; int r;
_cleanup_(unlink_tempfilep) char filename[] = "/tmp/test-unit_printf.XXXXXX"; _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 /* 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. */ * logic a second time. We're at least testing that the hookup works. */