]> git.ipfire.org Git - thirdparty/git.git/commitdiff
submodule--helper: fix trivial get_default_remote_submodule() leak
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Wed, 31 Aug 2022 23:14:09 +0000 (01:14 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 2 Sep 2022 16:18:12 +0000 (09:18 -0700)
Fix a leak in code added in 1012a5cbc3f (submodule--helper
run-update-procedure: learn --remote, 2022-03-04), we need to free()
the xstrdup()'d string. This gets e.g. t/t7419-submodule-set-branch.sh
closer to passing under SANITIZE=leak.

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>
builtin/submodule--helper.c

index d308b14904c867b2602e7d05417146ebf84e9990..d46ba102f60c456449593a597c6ffd96d07cdf02 100644 (file)
@@ -2448,6 +2448,8 @@ static int update_submodule(struct update_data *update_data)
                        return code;
                remote_ref = xstrfmt("refs/remotes/%s/%s", remote_name, branch);
 
+               free(remote_name);
+
                if (!update_data->nofetch) {
                        if (fetch_in_submodule(update_data->sm_path, update_data->depth,
                                              0, NULL))