Signed-off-by: Rene Scharfe <l.s.r@xxxxxx> --- sequencer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sequencer.c b/sequencer.c index fcceabb80f..60636ce54b 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1563,23 +1563,26 @@ static int create_seq_dir(void) static int save_head(const char *head) { static struct lock_file head_lock; struct strbuf buf = STRBUF_INIT; int fd; + ssize_t written; fd = hold_lock_file_for_update(&head_lock, git_path_head_file(), 0); if (fd < 0) { rollback_lock_file(&head_lock); return error_errno(_("could not lock HEAD")); } strbuf_addf(&buf, "%s\n", head); - if (write_in_full(fd, buf.buf, buf.len) < 0) { + written = write_in_full(fd, buf.buf, buf.len); + strbuf_release(&buf); + if (written < 0) { rollback_lock_file(&head_lock); return error_errno(_("could not write to '%s'"), git_path_head_file()); } if (commit_lock_file(&head_lock) < 0) { rollback_lock_file(&head_lock); return error(_("failed to finalize '%s'."), git_path_head_file()); } return 0; } -- 2.14.1