Skip to content

Commit ea78f9e

Browse files
committed
Merge branch 'ab/commit-plug-leaks'
Leakfix in the top-level called-once function. * ab/commit-plug-leaks: commit: fix "author_ident" leak
2 parents f9b9594 + 00d8c31 commit ea78f9e

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

builtin/commit.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,6 +1687,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
16871687
struct commit *current_head = NULL;
16881688
struct commit_extra_header *extra = NULL;
16891689
struct strbuf err = STRBUF_INIT;
1690+
int ret = 0;
16901691

16911692
if (argc == 2 && !strcmp(argv[1], "-h"))
16921693
usage_with_options(builtin_commit_usage, builtin_commit_options);
@@ -1721,8 +1722,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
17211722
running hooks, writing the trees, and interacting with the user. */
17221723
if (!prepare_to_commit(index_file, prefix,
17231724
current_head, &s, &author_ident)) {
1725+
ret = 1;
17241726
rollback_index_files();
1725-
return 1;
1727+
goto cleanup;
17261728
}
17271729

17281730
/* Determine parents */
@@ -1820,7 +1822,6 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
18201822
rollback_index_files();
18211823
die(_("failed to write commit object"));
18221824
}
1823-
strbuf_release(&author_ident);
18241825
free_commit_extra_headers(extra);
18251826

18261827
if (update_head_with_reflog(current_head, &oid, reflog_msg, &sb,
@@ -1862,7 +1863,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
18621863

18631864
apply_autostash(git_path_merge_autostash(the_repository));
18641865

1866+
cleanup:
1867+
UNLEAK(author_ident);
18651868
UNLEAK(err);
18661869
UNLEAK(sb);
1867-
return 0;
1870+
return ret;
18681871
}

t/t2203-add-intent.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
test_description='Intent to add'
44

5+
TEST_PASSES_SANITIZE_LEAK=true
56
. ./test-lib.sh
67

78
test_expect_success 'intent to add' '

t/t7011-skip-worktree-reading.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
test_description='skip-worktree bit test'
77

8+
TEST_PASSES_SANITIZE_LEAK=true
89
. ./test-lib.sh
910

1011
cat >expect.full <<EOF

0 commit comments

Comments
 (0)