From: Patrick Steinhardt Date: Wed, 01 Jul 2026 07:56:27 GMT Subject: Re: [PATCH 04/13] run-command: avoid close(-1) in start_command() error paths Message-ID: In-Reply-To: On Wed, Jul 01, 2026 at 07:04:22AM +0000, Johannes Schindelin via GitGitGadget wrote: > diff --git a/run-command.c b/run-command.c > index e70a8a387b..ce84db8782 100644 > --- a/run-command.c > +++ b/run-command.c > @@ -706,7 +706,7 @@ int start_command(struct child_process *cmd) > failed_errno = errno; > if (need_in) > close_pair(fdin); > - else if (cmd->in) > + else if (cmd->in > 0) > close(cmd->in); > str = "standard output"; > goto fail_pipe; > @@ -720,11 +720,11 @@ int start_command(struct child_process *cmd) > failed_errno = errno; > if (need_in) > close_pair(fdin); > - else if (cmd->in) > + else if (cmd->in > 0) > close(cmd->in); > if (need_out) > close_pair(fdout); > - else if (cmd->out) > + else if (cmd->out > 0) > close(cmd->out); > str = "standard error"; > fail_pipe: Right. There's a fourth site that does `close(cmd->out)`, but that site already guards with `if (cmd->out > 0)`. Patrick