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 <simon@ruderich.org> Reviewed-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent c8cee96 commit 9360ec0

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

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)