[PATCH v7 04/17] submodule--helper: "struct pathspec" memory leak in module_update()
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Aug 31, 2022, 23:14 UTC
- Message-ID
- <patch-v7-04.17-505d7d5077e-20220831T231003Z-avarab@gmail.com>
- In-Reply-To
- <cover-v7-00.17-00000000000-20220831T231003Z-avarab@gmail.com>
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> --- builtin/submodule--helper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 2f8603a6bb5..e8bc6f17330 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2564,6 +2564,7 @@ static int update_submodules(struct update_data *update_data) 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; @@ -2652,7 +2653,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; } @@ -2675,6 +2676,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; }
-- 2.37.3.1420.g76f8a3d556c