Skip to content

Commit 9360ec0

Browse files
rudisgitster
authored andcommitted
sequencer.c: check return value of close() in rewrite_file()
Not checking close(2) can hide errors as not all errors are reported during the write(2). Signed-off-by: Simon Ruderich <[email protected]> Reviewed-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c8cee96 commit 9360ec0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sequencer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2673,7 +2673,8 @@ static int rewrite_file(const char *path, const char *buf, size_t len)
26732673
return error_errno(_("could not open '%s' for writing"), path);
26742674
if (write_in_full(fd, buf, len) < 0)
26752675
rc = error_errno(_("could not write to '%s'"), path);
2676-
close(fd);
2676+
if (close(fd) && !rc)
2677+
rc = error_errno(_("could not close '%s'"), path);
26772678
return rc;
26782679
}
26792680

0 commit comments

Comments
 (0)