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>
Rene Scharfe committed
Aug 30, 2017 at 20:20 UTC
ed3f9a12d10c3a8aa3eace86e4d8139e723c2087
1 file changed
+4
-1
sequencer.c
+4
-1
@@ -1565,6 +1565,7 @@ static int save_head(const char *head)
1565
static struct lock_file head_lock;
1566
struct strbuf buf = STRBUF_INIT;
1567
int fd;
1568
+ ssize_t written;
1569
1570
fd = hold_lock_file_for_update(&head_lock, git_path_head_file(), 0);
1571
if (fd < 0) {
@@ -1572,7 +1573,9 @@ static int save_head(const char *head)
1573
return error_errno(_("could not lock HEAD"));
1574
}
1575
strbuf_addf(&buf, "%s\n", head);
1575
- if (write_in_full(fd, buf.buf, buf.len) < 0) {
1576
+ written = write_in_full(fd, buf.buf, buf.len);
1577
+ strbuf_release(&buf);
1578
+ if (written < 0) {
1579
rollback_lock_file(&head_lock);
1580
return error_errno(_("could not write to '%s'"),
1581
git_path_head_file());