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:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-09-02 16:18:12 (GMT)
commit4b9d12460d18d02bf6f12cc3c96340e53acf03e3 (patch)
treefb1edeb7ba896c0a5ccd4aab0786a9803d8eeef3 /builtin/submodule--helper.c
parent8fb201d4da0e9244f44dabdb1a5f5ea2809b2270 (diff)
downloadgit-4b9d12460d18d02bf6f12cc3c96340e53acf03e3.zip
git-4b9d12460d18d02bf6f12cc3c96340e53acf03e3.tar.gz
git-4b9d12460d18d02bf6f12cc3c96340e53acf03e3.tar.bz2
submodule--helper: "struct pathspec" memory leak in module_update()
The module_update() function calls module_list_compute() twice, which in turn will reset the "struct pathspec" passed to it. Let's instead track two of them, and clear them both. 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.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 4bba1c7..ef56471 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -2561,6 +2561,7 @@ cleanup:
static int module_update(int argc, const char **argv, const char *prefix)
{
struct pathspec pathspec = { 0 };
+ struct pathspec pathspec2 = { 0 };
struct update_data opt = UPDATE_DATA_INIT;
struct list_objects_filter_options filter_options = { 0 };
int ret;
@@ -2649,7 +2650,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
struct init_cb info = INIT_CB_INIT;
if (module_list_compute(argc, argv, opt.prefix,
- &pathspec, &list) < 0) {
+ &pathspec2, &list) < 0) {
ret = 1;
goto cleanup;
}
@@ -2672,6 +2673,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
cleanup:
list_objects_filter_release(&filter_options);
clear_pathspec(&pathspec);
+ clear_pathspec(&pathspec2);
return ret;
}