diff options
author | René Scharfe <l.s.r@web.de> | 2024-04-05 12:58:16 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-04-05 10:09:26 -0700 |
commit | 2b1f456adf8f0b574468661a65548106b317459b (patch) | |
tree | 5da3b7b2cc4cb7a3ef68c498c7128d19cae5e916 | |
parent | 3c2a3fdc388747b9eaf4a4a4f2035c1c9ddb26d0 (diff) | |
download | git-2b1f456adf8f0b574468661a65548106b317459b.tar.gz |
apply: don't leak fd on fdopen() error
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | apply.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -4644,8 +4644,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 |