From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Eric Sunshine" <sunshine@sunshineco.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH v2 3/9] test-tool {dump,scrap}-cache-tree: fix memory leaks
Date: Fri, 1 Jul 2022 12:37:34 +0200 [thread overview]
Message-ID: <patch-v2-3.9-5f9f34629c4-20220701T103503Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-v2-0.9-00000000000-20220701T103503Z-avarab@gmail.com>
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>
---
t/helper/test-dump-cache-tree.c | 7 ++++++-
t/helper/test-scrap-cache-tree.c | 1 +
t/t0090-cache-tree.sh | 2 ++
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/t/helper/test-dump-cache-tree.c b/t/helper/test-dump-cache-tree.c
index 6a3f88f5f5d..0d6d7f1ecbf 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 393f1604ff9..026c802479d 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");
diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh
index 90675726484..d8e2fc42e15 100755
--- a/t/t0090-cache-tree.sh
+++ b/t/t0090-cache-tree.sh
@@ -5,6 +5,8 @@ test_description="Test whether cache-tree is properly updated
Tests whether various commands properly update and/or rewrite the
cache-tree extension.
"
+
+TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
cmp_cache_tree () {
--
2.37.0.900.g4d0de1cceb2
next prev parent reply other threads:[~2022-07-01 10:51 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-30 23:47 [PATCH 0/9] test-tool: fix memory leaks Ævar Arnfjörð Bjarmason
2022-06-30 23:47 ` [PATCH 1/9] test-tool test-hash: fix a memory leak Ævar Arnfjörð Bjarmason
2022-06-30 23:47 ` [PATCH 2/9] test-tool path-utils: " Ævar Arnfjörð Bjarmason
2022-07-01 4:27 ` Eric Sunshine
2022-07-01 9:24 ` Ævar Arnfjörð Bjarmason
2022-06-30 23:47 ` [PATCH 3/9] test-tool {dump,scrap}-cache-tree: fix memory leaks Ævar Arnfjörð Bjarmason
2022-06-30 23:47 ` [PATCH 4/9] test-tool urlmatch-normalization: fix a memory leak Ævar Arnfjörð Bjarmason
2022-06-30 23:47 ` [PATCH 5/9] test-tool regex: call regfree(), fix memory leaks Ævar Arnfjörð Bjarmason
2022-07-01 2:17 ` Junio C Hamano
2022-06-30 23:47 ` [PATCH 6/9] test-tool json-writer: " Ævar Arnfjörð Bjarmason
2022-06-30 23:47 ` [PATCH 7/9] test-tool bloom: fix a memory leak Ævar Arnfjörð Bjarmason
2022-07-01 4:34 ` Eric Sunshine
2022-07-01 9:25 ` Ævar Arnfjörð Bjarmason
2022-06-30 23:47 ` [PATCH 8/9] test-tool ref-store: " Ævar Arnfjörð Bjarmason
2022-06-30 23:47 ` [PATCH 9/9] test-tool delta: " Ævar Arnfjörð Bjarmason
2022-07-01 10:37 ` [PATCH v2 0/9] test-tool: fix memory leaks Ævar Arnfjörð Bjarmason
2022-07-01 10:37 ` [PATCH v2 1/9] test-tool test-hash: fix a memory leak Ævar Arnfjörð Bjarmason
2022-07-01 10:37 ` [PATCH v2 2/9] test-tool path-utils: " Ævar Arnfjörð Bjarmason
2022-07-01 20:43 ` Junio C Hamano
2022-07-01 10:37 ` Ævar Arnfjörð Bjarmason [this message]
2022-07-01 10:37 ` [PATCH v2 4/9] test-tool urlmatch-normalization: " Ævar Arnfjörð Bjarmason
2022-07-01 10:37 ` [PATCH v2 5/9] test-tool regex: call regfree(), fix memory leaks Ævar Arnfjörð Bjarmason
2022-07-01 10:37 ` [PATCH v2 6/9] test-tool json-writer: " Ævar Arnfjörð Bjarmason
2022-07-01 10:37 ` [PATCH v2 7/9] test-tool bloom: " Ævar Arnfjörð Bjarmason
2022-07-01 10:37 ` [PATCH v2 8/9] test-tool ref-store: fix a memory leak Ævar Arnfjörð Bjarmason
2022-07-01 10:37 ` [PATCH v2 9/9] test-tool delta: " Ævar Arnfjörð Bjarmason
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=patch-v2-3.9-5f9f34629c4-20220701T103503Z-avarab@gmail.com \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).