]> git.ipfire.org Git - thirdparty/git.git/commitdiff
revisions API: call diff_free(&revs->pruning) in revisions_release()
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Wed, 13 Apr 2022 20:01:53 +0000 (22:01 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Apr 2022 06:56:10 +0000 (23:56 -0700)
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 886e1084d78 (builtin/: add UNLEAKs,
2017-10-01) for the commit that added the UNLEAK() there.

1. https://lore.kernel.org/git/220218.861r00ib86.gmgdl@evledraar.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/diff-index.c
builtin/diff.c
revision.c
t/t1001-read-tree-m-2way.sh
t/t1002-read-tree-m-u-2way.sh
t/t2200-add-update.sh
t/t4039-diff-assume-unchanged.sh
t/t4206-log-follow-harder-copies.sh
t/t6131-pathspec-icase.sh

index 3a83183c31232c818ffec6f7156901a77d861898..7d158af6b6d4a88de34569dedee0bb425c8f89e1 100644 (file)
@@ -70,7 +70,6 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
                return -1;
        }
        result = run_diff_index(&rev, option);
-       UNLEAK(rev);
        result = diff_result_code(&rev.diffopt, result);
        release_revisions(&rev);
        return result;
index dd48336da567b384966ebd1fe6e4fa489a6b3f60..f539132ac68afd47dbae4952fb09d676ce6d685e 100644 (file)
@@ -594,7 +594,6 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
        result = diff_result_code(&rev.diffopt, result);
        if (1 < rev.diffopt.skip_stat_unmatch)
                refresh_index_quietly();
-       UNLEAK(rev);
        release_revisions(&rev);
        UNLEAK(ent);
        UNLEAK(blob);
index 8cd849aa2b949d084e16a8ecdc90d46bbec7fdc4..63f17c085c9fefdf70f1944eb396c77e0420df7a 100644 (file)
@@ -2953,6 +2953,7 @@ void release_revisions(struct rev_info *revs)
        clear_pathspec(&revs->prune_data);
        release_revisions_mailmap(revs->mailmap);
        free_grep_patterns(&revs->grep_filter);
+       diff_free(&revs->pruning);
        reflog_walk_info_release(revs->reflog_info);
 }
 
index 0710b1fb1e945b4d15d989f65f83050076e592cf..516a6112fdcf1907fb3827cc23e7ad0b24b39099 100755 (executable)
@@ -21,6 +21,7 @@ In the test, these paths are used:
        yomin   - not in H or M
 '
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-read-tree.sh
 
index 46cbd5514a68e135222b5dbec77a21e170ccaa2b..bd5313caec9240b52bf9e8d663fd0c515d321064 100755 (executable)
@@ -9,6 +9,7 @@ This is identical to t1001, but uses -u to update the work tree as well.
 
 '
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-read-tree.sh
 
index 0c38f8e35695745c8eb02fe090c0d15b6d1666c8..be394f1131ac191476dfa228be6fc6f35e0cecd0 100755 (executable)
@@ -14,6 +14,7 @@ only the updates to dir/sub.
 Also tested are "git add -u" without limiting, and "git add -u"
 without contents changes, and other conditions'
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success setup '
index 0eb0314a8b35daecd3a442592bac4de1c480ffe0..78090e6852d5a8362e53414a1b4fc3302a24d874 100755 (executable)
@@ -2,6 +2,7 @@
 
 test_description='diff with assume-unchanged entries'
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 # external diff has been tested in t4020-diff-external.sh
index 4871a5dc92f0d586715728d667eefcf8c7644e00..33ecf82c7f98d3b9fb59422e614eb47cfe54fecb 100755 (executable)
@@ -6,6 +6,8 @@
 test_description='Test --follow should always find copies hard in git log.
 
 '
+
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-diff.sh
 
index 39fc3f6769be1c41d76c6acbfcb780b823afe7e7..770cce026cb158ab9a77eda336ff263c862fb0f8 100755 (executable)
@@ -1,6 +1,8 @@
 #!/bin/sh
 
 test_description='test case insensitive pathspec limiting'
+
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 if test_have_prereq CASE_INSENSITIVE_FS