On Tue, Jul 22, 2025 at 08:12:19AM +0000, Hoyoung Lee wrote: > When opening argv[3], if open() succeeds but fstat() fails, > the file descriptor is not closed, resulting in a resource leak. > This patch ensures that the descriptor is closed on failure. > > Signed-off-by: Hoyoung Lee <lhywkd22@xxxxxxxxx> > --- > builtin/archive.c | 3 ++- > t/helper/test-delta.c | 2 ++ > 2 files changed, 4 insertions(+), 1 deletion(-) > > diff --git a/builtin/archive.c b/builtin/archive.c > index c919a39f90..951fc2e444 100644 > --- a/builtin/archive.c > +++ b/builtin/archive.c > @@ -13,9 +13,10 @@ static void create_output_file(const char *output_file) > { > int output_fd = xopen(output_file, O_CREAT | O_WRONLY | O_TRUNC, 0666); > if (output_fd != 1) { > - if (dup2(output_fd, 1) < 0) > + if (dup2(output_fd, 1) < 0) { > close(output_fd); > die_errno(_("could not redirect output")); > + } > else > close(output_fd); > } Ah, I guess you found the problem from patch 3. But it should have been squashed in there, not to this patch. (But as I said there, I think we should just drop patch 3 entirely). -Peff