Skip to content

Commit 2b1f456

Browse files
rscharfegitster
authored andcommitted
apply: don't leak fd on fdopen() error
Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3c2a3fd commit 2b1f456

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

apply.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4644,8 +4644,11 @@ static int write_out_one_reject(struct apply_state *state, struct patch *patch)
46444644
return error_errno(_("cannot open %s"), namebuf);
46454645
}
46464646
rej = fdopen(fd, "w");
4647-
if (!rej)
4648-
return error_errno(_("cannot open %s"), namebuf);
4647+
if (!rej) {
4648+
error_errno(_("cannot open %s"), namebuf);
4649+
close(fd);
4650+
return -1;
4651+
}
46494652

46504653
/* Normal git tools never deal with .rej, so do not pretend
46514654
* this is a git patch by saying --git or giving extended

0 commit comments

Comments
 (0)