submodule--helper: fix most "struct pathspec" memory leaks
commit8fb201d4da0e9244f44dabdb1a5f5ea2809b2270
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Wed, 31 Aug 2022 23:14:10 +0000 (1 01:14 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 2 Sep 2022 16:18:12 +0000 (2 09:18 -0700)
treebe9f1778c6f3371c8c2bacb83212593e53af21cf
parentd76260e60a5c0379ca21a26bbded6d6426ae878f
submodule--helper: fix most "struct pathspec" memory leaks

Call clear_pathspec() at the end of various functions that work with
and allocate a "struct pathspec".

In some cases the zero-initialization here isn't strictly needed, but
as we're moving to a "goto cleanup" pattern let's make sure that it's
safe to call clear_pathspec(), we don't want the data to be
uninitialized.

E.g. for module_foreach() we can see from looking at
module_list_compute() that if it returns non-zero that the "pathspec"
will always have been initialized. But relying on that both assumes
knowledge about parse_pathspec(), and would set up a fragile pattern
going forward.

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