Skip to content

Commit

Permalink
builtin-mailinfo.c: check error status from rewind and ftruncate
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano authored and Shawn O. Pearce committed Sep 29, 2009
1 parent e0ab002 commit 1be224b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions builtin-mailinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,8 +785,10 @@ static int handle_commit_msg(struct strbuf *line)

if (use_scissors && is_scissors_line(line)) {
int i;
rewind(cmitmsg);
ftruncate(fileno(cmitmsg), 0);
if (fseek(cmitmsg, 0L, SEEK_SET))
die_errno("Could not rewind output message file");
if (ftruncate(fileno(cmitmsg), 0))
die_errno("Could not truncate output message file at scissors");
still_looking = 1;

/*
Expand Down

0 comments on commit 1be224b

Please sign in to comment.