test-tool test-hash: fix a memory leak

Fix a memory leak in "test-tool test-hash" which has been there since
b57cbbf8a8 (test-sha1: test hashing large buffer, 2006-06-24), as a
result we can mark more tests as passing with SANITIZE=leak using
"TEST_PASSES_SANITIZE_LEAK=true".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ævar Arnfjörð Bjarmason 2022-07-01 12:37:32 +02:00 committed by Junio C Hamano
parent e4a4b31577
commit 330ca8501b
5 changed files with 9 additions and 1 deletions

View File

@ -54,5 +54,6 @@ int cmd_hash_impl(int ac, const char **av, int algo)
fwrite(hash, 1, algop->rawsz, stdout); fwrite(hash, 1, algop->rawsz, stdout);
else else
puts(hash_to_hex_algop(hash, algop)); puts(hash_to_hex_algop(hash, algop));
free(buffer);
return 0; return 0;
} }

View File

@ -1,8 +1,9 @@
#!/bin/sh #!/bin/sh
test_description='test basic hash implementation' test_description='test basic hash implementation'
. ./test-lib.sh
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'test basic SHA-1 hash values' ' test_expect_success 'test basic SHA-1 hash values' '
test-tool sha1 </dev/null >actual && test-tool sha1 </dev/null >actual &&

View File

@ -1,6 +1,8 @@
#!/bin/sh #!/bin/sh
test_description='handling of duplicate objects in incoming packfiles' test_description='handling of duplicate objects in incoming packfiles'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh . ./test-lib.sh
. "$TEST_DIRECTORY"/lib-pack.sh . "$TEST_DIRECTORY"/lib-pack.sh

View File

@ -1,6 +1,8 @@
#!/bin/sh #!/bin/sh
test_description='test index-pack handling of delta cycles in packfiles' test_description='test index-pack handling of delta cycles in packfiles'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh . ./test-lib.sh
. "$TEST_DIRECTORY"/lib-pack.sh . "$TEST_DIRECTORY"/lib-pack.sh

View File

@ -6,6 +6,8 @@
test_description='git pack-object with "large" deltas test_description='git pack-object with "large" deltas
' '
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh . ./test-lib.sh
. "$TEST_DIRECTORY"/lib-pack.sh . "$TEST_DIRECTORY"/lib-pack.sh