Merge branch 'rs/apply-reject-fd-leakfix'

A file descriptor leak in an error codepath, used when "git apply
--reject" fails to create the *.rej file, has been corrected.

* rs/apply-reject-fd-leakfix:
  apply: don't leak fd on fdopen() error
This commit is contained in:
Junio C Hamano 2024-04-15 14:11:42 -07:00
commit ce729ea9ba
1 changed files with 5 additions and 2 deletions

View File

@ -4665,8 +4665,11 @@ static int write_out_one_reject(struct apply_state *state, struct patch *patch)
return error_errno(_("cannot open %s"), namebuf);
}
rej = fdopen(fd, "w");
if (!rej)
return error_errno(_("cannot open %s"), namebuf);
if (!rej) {
error_errno(_("cannot open %s"), namebuf);
close(fd);
return -1;
}
/* Normal git tools never deal with .rej, so do not pretend
* this is a git patch by saying --git or giving extended