Message ID | patch-v5-10.17-38345ec76bc-20220802T155002Z-avarab@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | submodule--helper: fix memory leaks | expand |
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 4e964a2c29c..902349976da 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -62,9 +62,13 @@ static char *repo_get_default_remote(struct repository *repo) static char *get_default_remote_submodule(const char *module_path) { struct repository subrepo; + char *ret; repo_submodule_init(&subrepo, the_repository, module_path, null_oid()); - return repo_get_default_remote(&subrepo); + ret = repo_get_default_remote(&subrepo); + repo_clear(&subrepo); + + return ret; } static char *get_default_remote(void)
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> --- builtin/submodule--helper.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)