aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-04-15 14:11:42 -0700
committerJunio C Hamano <gitster@pobox.com>2024-04-15 14:11:43 -0700
commitce729ea9bab9d115bdd2343c3ebe361fc6fce2c4 (patch)
treed09ce094c7537be1dec21f5c650f46ad329f4fc5
parentc7a9ec4728db6f88c0957789f3b77a3e2e8b0ec9 (diff)
parent2b1f456adf8f0b574468661a65548106b317459b (diff)
downloadgit-ce729ea9bab9d115bdd2343c3ebe361fc6fce2c4.tar.gz
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
-rw-r--r--apply.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/apply.c b/apply.c
index a5f716a705..34f20326a7 100644
--- a/apply.c
+++ b/apply.c
@@ -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