From bbc1f8de1c7bbad01666c6f46f85bb46c516bb39 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 11 Sep 2024 11:31:49 +1000 Subject: [PATCH] util: fix a leaking fd in a test --- src/util-strings.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util-strings.c b/src/util-strings.c index b721bd9..d013717 100644 --- a/src/util-strings.c +++ b/src/util-strings.c @@ -28,6 +28,7 @@ #include #include "util-strings.h" +#include "util-io.h" /** * Return the next word in a string pointed to by state before the first @@ -516,7 +517,7 @@ MUNIT_TEST(test_cmdline_as_str) xsnprintf(cmdline, sizeof(cmdline), "/proc/%i/cmdline", getpid()); - int fd = open(cmdline, O_RDONLY); + _cleanup_close_ int fd = open(cmdline, O_RDONLY); munit_assert_int(fd, >=, 0); int len = read(fd, cmdline, sizeof(cmdline) - 1); munit_assert_int(len, >=, 0);