summaryrefslogtreecommitdiff
path: root/builtin/submodule--helper.c
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2022-08-31 23:14:17 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-09-02 16:18:13 (GMT)
commitae3ef94d9bc61931636647c4eab558e09aaeb50a (patch)
tree117246f3475645e8fbd254abe7ee5603a440568a /builtin/submodule--helper.c
parent17af0a8444523f4df98e21165a3e476f05749237 (diff)
downloadgit-ae3ef94d9bc61931636647c4eab558e09aaeb50a.zip
git-ae3ef94d9bc61931636647c4eab558e09aaeb50a.tar.gz
git-ae3ef94d9bc61931636647c4eab558e09aaeb50a.tar.bz2
submodule--helper: fix a memory leak in get_default_remote_submodule()
Fix a memory leak in the get_default_remote_submodule() function added in a77c3fcb5ec (submodule--helper: get remote names from any repository, 2022-03-04), we need to repo_clear() the submodule we initialize. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Reviewed-by: Glen Choo <chooglen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/submodule--helper.c')
-rw-r--r--builtin/submodule--helper.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 79ffcb5..8866af2 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -65,12 +65,16 @@ static int repo_get_default_remote(struct repository *repo, char **default_remot
static int get_default_remote_submodule(const char *module_path, char **default_remote)
{
struct repository subrepo;
+ int ret;
if (repo_submodule_init(&subrepo, the_repository, module_path,
null_oid()) < 0)
return die_message(_("could not get a repository handle for submodule '%s'"),
module_path);
- return repo_get_default_remote(&subrepo, default_remote);
+ ret = repo_get_default_remote(&subrepo, default_remote);
+ repo_clear(&subrepo);
+
+ return ret;
}
static char *get_default_remote(void)