@matheusbsbs / matheus-bagliano / commits / 1be224ba6e
Fork 0

builtin-mailinfo.c: check error status from rewind and ftruncate

A recent "cut at scissors" implementation rewinds and truncates the output file to store the message when it sees a scissors mark, but it did not check if these library calls succeeded. Signed-off-by: Junio C Hamano <gitster@pobox.com> [sp: Use fseek as rewind returns void] Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Junio C Hamano committed Sep 28, 2009 at 23:40 UTC 1be224ba6e99f0ab34c998d7fa8023b76a15c8b6
1 file changed +4 -2
builtin-mailinfo.c
+4 -2
@@ -785,8 +785,10 @@ static int handle_commit_msg(struct strbuf *line)
785
786 if (use_scissors && is_scissors_line(line)) {
787 int i;
788 - rewind(cmitmsg);
789 - ftruncate(fileno(cmitmsg), 0);
788 + if (fseek(cmitmsg, 0L, SEEK_SET))
789 + die_errno("Could not rewind output message file");
790 + if (ftruncate(fileno(cmitmsg), 0))
791 + die_errno("Could not truncate output message file at scissors");
792 still_looking = 1;
793
794 /*