diff --git a/builtin/bisect.c b/builtin/bisect.c index ceb60b0626..733d28d377 100644 --- a/builtin/bisect.c +++ b/builtin/bisect.c @@ -1308,7 +1308,12 @@ static int bisect_run(struct bisect_terms *terms, int argc, const char **argv) fflush(stdout); saved_stdout = dup(1); - dup2(temporary_stdout_fd, 1); + if (saved_stdout < 0 || + dup2(temporary_stdout_fd, 1) < 0) { + res = error_errno(_("could not duplicate stdout")); + close(temporary_stdout_fd); + break; + } res = bisect_state(terms, 1, &new_state);