]> git.ipfire.org Git - thirdparty/git.git/commitdiff
test-tool bloom: fix memory leaks
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 1 Jul 2022 10:37:38 +0000 (12:37 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 1 Jul 2022 20:38:50 +0000 (13:38 -0700)
Fix memory leaks introduced with these tests in f1294eaf7fb (bloom.c:
introduce core Bloom filter constructs, 2020-03-30), as a result we
can mark almost the entirety of t0095-bloom.sh as passing with
SANITIZE=leak using "TEST_PASSES_SANITIZE_LEAK=true", there's still an
unrelated memory leak in "git commit" in one of the tests, let's skip
that one under SANITIZE_LEAK for now.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/helper/test-bloom.c
t/t0095-bloom.sh

index ad3ef1cd77ae1b98db3c46980d1439f1ca5f56e7..6c900ca668467dcdbc92c6544ad173565c3a5f08 100644 (file)
@@ -16,6 +16,7 @@ static void add_string_to_filter(const char *data, struct bloom_filter *filter)
                }
                printf("\n");
                add_key_to_filter(&key, filter, &settings);
+               clear_bloom_key(&key);
 }
 
 static void print_bloom_filter(struct bloom_filter *filter) {
@@ -80,6 +81,7 @@ int cmd__bloom(int argc, const char **argv)
                }
 
                print_bloom_filter(&filter);
+               free(filter.data);
        }
 
        if (!strcmp(argv[1], "get_filter_for_commit")) {
index 5945973552a6af6ac1971920b573086b081f6160..daeb4a5e3e7514ea0bba1e10af58d5249b45e555 100755 (executable)
@@ -67,7 +67,7 @@ test_expect_success 'compute bloom key for test string 2' '
        test_cmp expect actual
 '
 
-test_expect_success 'get bloom filters for commit with no changes' '
+test_expect_success !SANITIZE_LEAK 'get bloom filters for commit with no changes' '
        git init &&
        git commit --allow-empty -m "c0" &&
        cat >expect <<-\EOF &&