git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: git@vger.kernel.org
Subject: [PATCH 1/4] test-bloom: stop setting up Git directory twice
Date: Mon, 6 Nov 2023 11:45:53 +0100	[thread overview]
Message-ID: <fb1cc73ed3395ba3de72aba70d7679dd85ebb034.1699267422.git.ps@pks.im> (raw)
In-Reply-To: <cover.1699267422.git.ps@pks.im>

[-- Attachment #1: Type: text/plain, Size: 1014 bytes --]

We're setting up the Git directory twice in the `test-tool bloom`
helper, once at the beginning of `cmd_bloom()` and once in the local
subcommand implementation `get_bloom_filter_for_commit()`. This can lead
to memory leaks as we'll overwrite variables of `the_repository` with
newly allocated data structures. On top of that it's simply unnecessary.

Fix this by only setting up the Git directory once.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 t/helper/test-bloom.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/t/helper/test-bloom.c b/t/helper/test-bloom.c
index aabe31d724b..1281e66876f 100644
--- a/t/helper/test-bloom.c
+++ b/t/helper/test-bloom.c
@@ -40,7 +40,6 @@ static void get_bloom_filter_for_commit(const struct object_id *commit_oid)
 {
 	struct commit *c;
 	struct bloom_filter *filter;
-	setup_git_directory();
 	c = lookup_commit(the_repository, commit_oid);
 	filter = get_or_compute_bloom_filter(the_repository, c, 1,
 					     &settings,
-- 
2.42.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2023-11-06 10:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-06 10:45 [PATCH 0/4] Memory leak fixes Patrick Steinhardt
2023-11-06 10:45 ` Patrick Steinhardt [this message]
2023-11-06 17:20   ` [PATCH 1/4] test-bloom: stop setting up Git directory twice Jeff King
2023-11-06 10:45 ` [PATCH 2/4] shallow: fix memory leak when registering shallow roots Patrick Steinhardt
2023-11-06 17:21   ` Jeff King
2023-11-06 10:46 ` [PATCH 3/4] setup: refactor `upgrade_repository_format()` to have common exit Patrick Steinhardt
2023-11-06 10:46 ` [PATCH 4/4] setup: fix leaking repository format Patrick Steinhardt
2023-11-06 17:32 ` [PATCH 0/4] Memory leak fixes Jeff King
2023-11-07  2:20   ` Junio C Hamano

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fb1cc73ed3395ba3de72aba70d7679dd85ebb034.1699267422.git.ps@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    /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.
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 NNTP newsgroup(s).