diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-02-22 13:38:15 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-02-22 13:50:52 +0100 |
commit | 282696ce52471f5e3c963b9d98dbc89fba3a1fba (patch) | |
tree | cffc84d65286a8981c32dfe295e90e24ee6e7e21 /src/oom | |
parent | test: fix memory and fd leak in test-dhcp6-client (diff) | |
download | systemd-282696ce52471f5e3c963b9d98dbc89fba3a1fba.tar.xz systemd-282696ce52471f5e3c963b9d98dbc89fba3a1fba.zip |
test: fix file descriptor leak in test-oomd-util
Fixes an issue reported in #22576.
Diffstat (limited to 'src/oom')
-rw-r--r-- | src/oom/test-oomd-util.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/oom/test-oomd-util.c b/src/oom/test-oomd-util.c index 265e77c0a2..0252ceecd7 100644 --- a/src/oom/test-oomd-util.c +++ b/src/oom/test-oomd-util.c @@ -5,6 +5,7 @@ #include "alloc-util.h" #include "cgroup-setup.h" #include "cgroup-util.h" +#include "fd-util.h" #include "fileio.h" #include "fs-util.h" #include "oomd-util.h" @@ -13,6 +14,7 @@ #include "string-util.h" #include "strv.h" #include "tests.h" +#include "tmpfile-util.h" static int fork_and_sleep(unsigned sleep_min) { usec_t n, timeout, ts; @@ -244,12 +246,13 @@ static void test_oomd_update_cgroup_contexts_between_hashmaps(void) { static void test_oomd_system_context_acquire(void) { _cleanup_(unlink_tempfilep) char path[] = "/oomdgetsysctxtestXXXXXX"; + _cleanup_close_ int fd = -1; OomdSystemContext ctx; if (geteuid() != 0) return (void) log_tests_skipped("not root"); - assert_se(mkstemp(path)); + assert_se((fd = mkostemp_safe(path)) >= 0); assert_se(oomd_system_context_acquire("/verylikelynonexistentpath", &ctx) == -ENOENT); |