summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRene Scharfe <l.s.r@web.de>2017-08-30 20:20:14 +0200
committerJunio C Hamano <gitster@pobox.com>2017-09-07 08:49:28 +0900
commited3f9a12d10c3a8aa3eace86e4d8139e723c2087 (patch)
tree62ff947819af527debf703dc6f817b3ccef815bd
parent557d3185ee22ec44bb6965467b14a76d9c33e571 (diff)
downloadgit-ed3f9a12d10c3a8aa3eace86e4d8139e723c2087.tar.gz
sequencer: release strbuf after use in save_head()
Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--sequencer.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sequencer.c b/sequencer.c
index fcceabb80f..60636ce54b 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1565,6 +1565,7 @@ 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) {
@@ -1572,7 +1573,9 @@ static int save_head(const char *head)
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());