Skip to content

Commit d34b5cb

Browse files
pks-tgitster
authored andcommitted
builtin/commit: fix leaking change data contents
While we free the worktree change data, we never free its contents. Fix this. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3b37315 commit d34b5cb

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

builtin/commit.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,13 @@ static void prepare_amend_commit(struct commit *commit, struct strbuf *sb,
728728
repo_unuse_commit_buffer(the_repository, commit, buffer);
729729
}
730730

731+
static void change_data_free(void *util, const char *str UNUSED)
732+
{
733+
struct wt_status_change_data *d = util;
734+
free(d->rename_source);
735+
free(d);
736+
}
737+
731738
static int prepare_to_commit(const char *index_file, const char *prefix,
732739
struct commit *current_head,
733740
struct wt_status *s,
@@ -991,7 +998,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
991998
s->use_color = 0;
992999
committable = run_status(s->fp, index_file, prefix, 1, s);
9931000
s->use_color = saved_color_setting;
994-
string_list_clear(&s->change, 1);
1001+
string_list_clear_func(&s->change, change_data_free);
9951002
} else {
9961003
struct object_id oid;
9971004
const char *parent = "HEAD";

t/t7500-commit-template-squash-signoff.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ test_description='git commit
77
88
Tests for template, signoff, squash and -F functions.'
99

10+
TEST_PASSES_SANITIZE_LEAK=true
1011
. ./test-lib.sh
1112

1213
. "$TEST_DIRECTORY"/lib-rebase.sh

0 commit comments

Comments
 (0)