From: Hoyoung Lee Date: Tue, 22 Jul 2025 08:12:18 GMT Subject: [PATCH v2 3/4] t/helper/test-delta: close fd if fstat() fails after open() Message-ID: <20250722081219.1086866-4-lhywkd22@gmail.com> In-Reply-To: <20250722081219.1086866-1-lhywkd22@gmail.com> If open() succeeds but fstat() fails, the file descriptor is not closed, causing a resource leak. This patch adds a close(fd) call in the failure path after fstat() to ensure proper resource cleanup. Signed-off-by: Hoyoung Lee --- t/helper/test-delta.c | 1 + 1 file changed, 1 insertion(+) diff --git a/t/helper/test-delta.c b/t/helper/test-delta.c index 6bc787a474..103bf7f3e9 100644 --- a/t/helper/test-delta.c +++ b/t/helper/test-delta.c @@ -31,6 +31,7 @@ int cmd__delta(int argc, const char **argv) fd = open(argv[2], O_RDONLY); if (fd < 0 || fstat(fd, &st)) { perror(argv[2]); + close(fd); return 1; } from_size = st.st_size; -- 2.34.1