All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Derrick Stolee" <derrickstolee@github.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH v2 04/14] urlmatch.c: add and use a *_release() function
Date: Fri,  4 Mar 2022 19:32:07 +0100	[thread overview]
Message-ID: <patch-v2-04.14-d51f6ae0963-20220304T182902Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-v2-00.14-00000000000-20220304T182902Z-avarab@gmail.com>

Plug a memory leak in credential_apply_config() by adding and using a
new urlmatch_config_release() function. This just does a
string_list_clear() on the "vars" member.

This finished up work on normalizing the init/free pattern in this
API, started in 73ee449bbf2 (urlmatch.[ch]: add and use
URLMATCH_CONFIG_INIT, 2021-10-01).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/config.c | 2 +-
 credential.c     | 1 +
 urlmatch.c       | 5 +++++
 urlmatch.h       | 1 +
 4 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/builtin/config.c b/builtin/config.c
index 542d8d02b2b..ebec61868be 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -612,7 +612,7 @@ static int get_urlmatch(const char *var, const char *url)
 
 		strbuf_release(&matched->value);
 	}
-	string_list_clear(&config.vars, 1);
+	urlmatch_config_release(&config);
 	string_list_clear(&values, 1);
 	free(config.url.url);
 
diff --git a/credential.c b/credential.c
index e7240f3f636..f6389a50684 100644
--- a/credential.c
+++ b/credential.c
@@ -130,6 +130,7 @@ static void credential_apply_config(struct credential *c)
 	git_config(urlmatch_config_entry, &config);
 	string_list_clear(&config.vars, 1);
 	free(normalized_url);
+	urlmatch_config_release(&config);
 	strbuf_release(&url);
 
 	c->configured = 1;
diff --git a/urlmatch.c b/urlmatch.c
index 03ad3f30a9c..b615adc923a 100644
--- a/urlmatch.c
+++ b/urlmatch.c
@@ -611,3 +611,8 @@ int urlmatch_config_entry(const char *var, const char *value, void *cb)
 	strbuf_release(&synthkey);
 	return retval;
 }
+
+void urlmatch_config_release(struct urlmatch_config *config)
+{
+	string_list_clear(&config->vars, 1);
+}
diff --git a/urlmatch.h b/urlmatch.h
index 34a3ba6d197..9f40b00bfb8 100644
--- a/urlmatch.h
+++ b/urlmatch.h
@@ -71,5 +71,6 @@ struct urlmatch_config {
 }
 
 int urlmatch_config_entry(const char *var, const char *value, void *cb);
+void urlmatch_config_release(struct urlmatch_config *config);
 
 #endif /* URL_MATCH_H */
-- 
2.35.1.1248.gb68c9165ad8


  parent reply	other threads:[~2022-03-04 18:32 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-02 17:10 [PATCH 00/14] tree-wide: small fixes for memory leaks Ævar Arnfjörð Bjarmason
2022-03-02 17:10 ` [PATCH 01/14] index-pack: fix " Ævar Arnfjörð Bjarmason
2022-03-02 20:36   ` Derrick Stolee
2022-03-03 16:19     ` Ævar Arnfjörð Bjarmason
2022-03-02 17:10 ` [PATCH 02/14] merge-base: free() allocated "struct commit **" list Ævar Arnfjörð Bjarmason
2022-03-02 17:10 ` [PATCH 03/14] diff.c: free "buf" in diff_words_flush() Ævar Arnfjörð Bjarmason
2022-03-02 17:10 ` [PATCH 04/14] urlmatch.c: add and use a *_release() function Ævar Arnfjörð Bjarmason
2022-03-02 17:10 ` [PATCH 05/14] remote-curl.c: free memory in cmd_main() Ævar Arnfjörð Bjarmason
2022-03-02 17:10 ` [PATCH 06/14] bundle: call strvec_clear() on allocated strvec Ævar Arnfjörð Bjarmason
2022-03-02 17:10 ` [PATCH 07/14] transport: stop needlessly copying bundle header references Ævar Arnfjörð Bjarmason
2022-03-02 20:47   ` Derrick Stolee
2022-03-03 16:20     ` Ævar Arnfjörð Bjarmason
2022-03-02 17:10 ` [PATCH 08/14] submodule--helper: fix trivial leak in module_add() Ævar Arnfjörð Bjarmason
2022-03-02 17:10 ` [PATCH 09/14] commit-graph: fix memory leak in misused string_list API Ævar Arnfjörð Bjarmason
2022-03-02 17:10 ` [PATCH 10/14] commit-graph: stop fill_oids_from_packs() progress on error and free() Ævar Arnfjörð Bjarmason
2022-03-02 17:10 ` [PATCH 11/14] lockfile API users: simplify and don't leak "path" Ævar Arnfjörð Bjarmason
2022-03-02 17:10 ` [PATCH 12/14] range-diff: plug memory leak in common invocation Ævar Arnfjörð Bjarmason
2022-03-02 17:10 ` [PATCH 13/14] range-diff: plug memory leak in read_patches() Ævar Arnfjörð Bjarmason
2022-03-02 17:10 ` [PATCH 14/14] repository.c: free the "path cache" in repo_clear() Ævar Arnfjörð Bjarmason
2022-03-02 20:58 ` [PATCH 00/14] tree-wide: small fixes for memory leaks Derrick Stolee
2022-03-04 18:32 ` [PATCH v2 " Ævar Arnfjörð Bjarmason
2022-03-04 18:32   ` [PATCH v2 01/14] index-pack: fix " Ævar Arnfjörð Bjarmason
2022-03-04 18:32   ` [PATCH v2 02/14] merge-base: free() allocated "struct commit **" list Ævar Arnfjörð Bjarmason
2022-03-04 18:32   ` [PATCH v2 03/14] diff.c: free "buf" in diff_words_flush() Ævar Arnfjörð Bjarmason
2022-03-04 18:32   ` Ævar Arnfjörð Bjarmason [this message]
2022-03-04 18:32   ` [PATCH v2 05/14] remote-curl.c: free memory in cmd_main() Ævar Arnfjörð Bjarmason
2022-03-04 18:32   ` [PATCH v2 06/14] bundle: call strvec_clear() on allocated strvec Ævar Arnfjörð Bjarmason
2022-03-04 18:32   ` [PATCH v2 07/14] transport: stop needlessly copying bundle header references Ævar Arnfjörð Bjarmason
2022-03-04 19:10     ` Derrick Stolee
2022-03-04 18:32   ` [PATCH v2 08/14] submodule--helper: fix trivial leak in module_add() Ævar Arnfjörð Bjarmason
2022-03-04 18:32   ` [PATCH v2 09/14] commit-graph: fix memory leak in misused string_list API Ævar Arnfjörð Bjarmason
2022-03-04 18:32   ` [PATCH v2 10/14] commit-graph: stop fill_oids_from_packs() progress on error and free() Ævar Arnfjörð Bjarmason
2022-03-04 18:32   ` [PATCH v2 11/14] lockfile API users: simplify and don't leak "path" Ævar Arnfjörð Bjarmason
2022-03-04 18:32   ` [PATCH v2 12/14] range-diff: plug memory leak in common invocation Ævar Arnfjörð Bjarmason
2022-03-04 18:32   ` [PATCH v2 13/14] range-diff: plug memory leak in read_patches() Ævar Arnfjörð Bjarmason
2022-03-04 18:32   ` [PATCH v2 14/14] repository.c: free the "path cache" in repo_clear() Ævar Arnfjörð Bjarmason
2022-03-04 19:11   ` [PATCH v2 00/14] tree-wide: small fixes for memory leaks Derrick Stolee

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=patch-v2-04.14-d51f6ae0963-20220304T182902Z-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=derrickstolee@github.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.