Skip to content

Commit ed3f9a1

Browse files
rscharfegitster
authored andcommitted
sequencer: release strbuf after use in save_head()
Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 557d318 commit ed3f9a1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sequencer.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1565,14 +1565,17 @@ static int save_head(const char *head)
15651565
static struct lock_file head_lock;
15661566
struct strbuf buf = STRBUF_INIT;
15671567
int fd;
1568+
ssize_t written;
15681569

15691570
fd = hold_lock_file_for_update(&head_lock, git_path_head_file(), 0);
15701571
if (fd < 0) {
15711572
rollback_lock_file(&head_lock);
15721573
return error_errno(_("could not lock HEAD"));
15731574
}
15741575
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) {
15761579
rollback_lock_file(&head_lock);
15771580
return error_errno(_("could not write to '%s'"),
15781581
git_path_head_file());

0 commit comments

Comments
 (0)