Skip to content

Commit 6ab75ac

Browse files
avargitster
authored andcommitted
revisions API: call diff_free(&revs->pruning) in revisions_release()
Call diff_free() on the "pruning" member of "struct rev_info". Doing so makes several tests pass under SANITIZE=leak. This was also the last missing piece that allows us to remove the UNLEAK() in "cmd_diff" and "cmd_diff_index", which allows us to use those commands as a canary for general leaks in the revisions API. See [1] for further rationale, and 886e108 (builtin/: add UNLEAKs, 2017-10-01) for the commit that added the UNLEAK() there. 1. https://lore.kernel.org/git/[email protected]/ Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 81ffbf8 commit 6ab75ac

9 files changed

+9
-2
lines changed

builtin/diff-index.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
7070
return -1;
7171
}
7272
result = run_diff_index(&rev, option);
73-
UNLEAK(rev);
7473
result = diff_result_code(&rev.diffopt, result);
7574
release_revisions(&rev);
7675
return result;

builtin/diff.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,6 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
594594
result = diff_result_code(&rev.diffopt, result);
595595
if (1 < rev.diffopt.skip_stat_unmatch)
596596
refresh_index_quietly();
597-
UNLEAK(rev);
598597
release_revisions(&rev);
599598
UNLEAK(ent);
600599
UNLEAK(blob);

revision.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2953,6 +2953,7 @@ void release_revisions(struct rev_info *revs)
29532953
clear_pathspec(&revs->prune_data);
29542954
release_revisions_mailmap(revs->mailmap);
29552955
free_grep_patterns(&revs->grep_filter);
2956+
diff_free(&revs->pruning);
29562957
reflog_walk_info_release(revs->reflog_info);
29572958
}
29582959

t/t1001-read-tree-m-2way.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ In the test, these paths are used:
2121
yomin - not in H or M
2222
'
2323

24+
TEST_PASSES_SANITIZE_LEAK=true
2425
. ./test-lib.sh
2526
. "$TEST_DIRECTORY"/lib-read-tree.sh
2627

t/t1002-read-tree-m-u-2way.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This is identical to t1001, but uses -u to update the work tree as well.
99
1010
'
1111

12+
TEST_PASSES_SANITIZE_LEAK=true
1213
. ./test-lib.sh
1314
. "$TEST_DIRECTORY"/lib-read-tree.sh
1415

t/t2200-add-update.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ only the updates to dir/sub.
1414
Also tested are "git add -u" without limiting, and "git add -u"
1515
without contents changes, and other conditions'
1616

17+
TEST_PASSES_SANITIZE_LEAK=true
1718
. ./test-lib.sh
1819

1920
test_expect_success setup '

t/t4039-diff-assume-unchanged.sh

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

33
test_description='diff with assume-unchanged entries'
44

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

78
# external diff has been tested in t4020-diff-external.sh

t/t4206-log-follow-harder-copies.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
test_description='Test --follow should always find copies hard in git log.
77
88
'
9+
10+
TEST_PASSES_SANITIZE_LEAK=true
911
. ./test-lib.sh
1012
. "$TEST_DIRECTORY"/lib-diff.sh
1113

t/t6131-pathspec-icase.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/sh
22

33
test_description='test case insensitive pathspec limiting'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
46
. ./test-lib.sh
57

68
if test_have_prereq CASE_INSENSITIVE_FS

0 commit comments

Comments
 (0)