summaryrefslogtreecommitdiff
path: root/t/helper
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2022-07-01 10:37:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-07-01 20:38:49 (GMT)
commit9afa46d4a677c806f414f363daee07a9e6a44f0b (patch)
tree75ae5319e47c71b52d231c1844d56a0c5443af77 /t/helper
parente287a5b0a434e05de39ede507e5b3fc24f67cbb0 (diff)
downloadgit-9afa46d4a677c806f414f363daee07a9e6a44f0b.zip
git-9afa46d4a677c806f414f363daee07a9e6a44f0b.tar.gz
git-9afa46d4a677c806f414f363daee07a9e6a44f0b.tar.bz2
test-tool {dump,scrap}-cache-tree: fix memory leaks
Fix memory leaks in two test-tools used by t0090-cache-tree.sh. As a result we can mark the test 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>
Diffstat (limited to 't/helper')
-rw-r--r--t/helper/test-dump-cache-tree.c7
-rw-r--r--t/helper/test-scrap-cache-tree.c1
2 files changed, 7 insertions, 1 deletions
diff --git a/t/helper/test-dump-cache-tree.c b/t/helper/test-dump-cache-tree.c
index 6a3f88f..0d6d7f1 100644
--- a/t/helper/test-dump-cache-tree.c
+++ b/t/helper/test-dump-cache-tree.c
@@ -59,11 +59,16 @@ int cmd__dump_cache_tree(int ac, const char **av)
{
struct index_state istate;
struct cache_tree *another = cache_tree();
+ int ret;
+
setup_git_directory();
if (read_cache() < 0)
die("unable to read index file");
istate = the_index;
istate.cache_tree = another;
cache_tree_update(&istate, WRITE_TREE_DRY_RUN);
- return dump_cache_tree(active_cache_tree, another, "");
+ ret = dump_cache_tree(active_cache_tree, another, "");
+ cache_tree_free(&another);
+
+ return ret;
}
diff --git a/t/helper/test-scrap-cache-tree.c b/t/helper/test-scrap-cache-tree.c
index 393f160..026c802 100644
--- a/t/helper/test-scrap-cache-tree.c
+++ b/t/helper/test-scrap-cache-tree.c
@@ -12,6 +12,7 @@ int cmd__scrap_cache_tree(int ac, const char **av)
hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
if (read_cache() < 0)
die("unable to read index file");
+ cache_tree_free(&active_cache_tree);
active_cache_tree = NULL;
if (write_locked_index(&the_index, &index_lock, COMMIT_LOCK))
die("unable to write index file");