Skip to content

Commit 465028e

Browse files
avargitster
authored andcommitted
merge: add missing strbuf_release()
We strbuf_reset() this "struct strbuf" in a loop earlier, but never freed it. Plugs a memory leak that's been here ever since this code got introduced in 1c7b76b (Build in merge, 2008-07-07). This takes us from 68 failed tests in "t7600-merge.sh" to 59 under SANITIZE=leak, and makes "t7604-merge-custom-message.sh" pass! Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 272f0a5 commit 465028e

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

builtin/merge.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,6 +1576,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
15761576

15771577
finish(head_commit, remoteheads, &commit->object.oid, msg.buf);
15781578
remove_merge_branch_state(the_repository);
1579+
strbuf_release(&msg);
15791580
goto done;
15801581
} else if (!remoteheads->next && common->next)
15811582
;
@@ -1746,6 +1747,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
17461747
ret = suggest_conflicts();
17471748

17481749
done:
1750+
strbuf_release(&buf);
17491751
free(branch_to_free);
17501752
return ret;
17511753
}

t/t7604-merge-custom-message.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ test_description='git merge
44
55
Testing merge when using a custom message for the merge commit.'
66

7+
TEST_PASSES_SANITIZE_LEAK=true
78
. ./test-lib.sh
89

910
create_merge_msgs() {

0 commit comments

Comments
 (0)