]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t/helper/test-truncate: close file descriptor after truncation
authorHoyoung Lee <lhywkd22@gmail.com>
Tue, 22 Jul 2025 17:41:01 +0000 (17:41 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 22 Jul 2025 21:05:34 +0000 (14:05 -0700)
Fix a resource leak where the file descriptor was not closed after
truncating a file in t/helper/test-truncate.c.

Signed-off-by: Hoyoung Lee <lhywkd22@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/helper/test-truncate.c

index 3931deaec7dcdaec9789bc03e09f0ae5cb3b0d3e..2820cc7ed701cd4d66362b9a70dbb1abed8cc976 100644 (file)
@@ -21,5 +21,8 @@ int cmd__truncate(int argc, const char **argv)
 
        if (ftruncate(fd, (off_t) sz) < 0)
                die_errno("failed to truncate file");
+
+       close(fd);
+
        return 0;
 }