Re: [PATCH 11/11] bisect: handle dup() failure when redirecting stdout

Johannes Schindelin <[email protected]> Wed, 5 Aug 2026 18:44:53 +0200 (CEST)
Newsgroups org.kernel.vger.git
Message-ID <[email protected]>
Hi Patrick,

On Wed, 15 Jul 2026, Patrick Steinhardt wrote:

> On Tue, Jul 14, 2026 at 10:48:44PM +0000, Johannes Schindelin via GitGitGadget wrote:
> > diff --git a/builtin/bisect.c b/builtin/bisect.c
> > index 15a2a30f89..801daf8c78 100644
> > --- a/builtin/bisect.c
> > +++ b/builtin/bisect.c
> > @@ -1308,6 +1308,11 @@ static int bisect_run(struct bisect_terms *terms, int argc, const char **argv)
> >  
> >  		fflush(stdout);
> >  		saved_stdout = dup(1);
> > +		if (saved_stdout < 0) {
> > +			res = error_errno(_("could not duplicate stdout"));
> > +			close(temporary_stdout_fd);
> > +			break;
> > +		}
> >  		dup2(temporary_stdout_fd, 1);
> 
> Shouldn't we also verify the return value of `dup2()` while at it?

True. I wonder why Coverity didn't complain... funny. I changed it to also
check the return value of `dup2()`.

Thank you for your review!
Johannes