Skip to content

Commit 4b9d124

Browse files
avargitster
authored andcommitted
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 <[email protected]> Reviewed-by: Glen Choo <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8fb201d commit 4b9d124

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

builtin/submodule--helper.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2561,6 +2561,7 @@ static int update_submodules(struct update_data *update_data)
25612561
static int module_update(int argc, const char **argv, const char *prefix)
25622562
{
25632563
struct pathspec pathspec = { 0 };
2564+
struct pathspec pathspec2 = { 0 };
25642565
struct update_data opt = UPDATE_DATA_INIT;
25652566
struct list_objects_filter_options filter_options = { 0 };
25662567
int ret;
@@ -2649,7 +2650,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
26492650
struct init_cb info = INIT_CB_INIT;
26502651

26512652
if (module_list_compute(argc, argv, opt.prefix,
2652-
&pathspec, &list) < 0) {
2653+
&pathspec2, &list) < 0) {
26532654
ret = 1;
26542655
goto cleanup;
26552656
}
@@ -2672,6 +2673,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
26722673
cleanup:
26732674
list_objects_filter_release(&filter_options);
26742675
clear_pathspec(&pathspec);
2676+
clear_pathspec(&pathspec2);
26752677
return ret;
26762678
}
26772679

0 commit comments

Comments
 (0)