[PATCH v2 14/27] revisions API users: use release_revisions() in submodule.c edge case
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Mar 23, 2022, 20:32 UTC
- Message-ID
- <patch-v2-14.27-38f4f1c4ecb-20220323T203149Z-avarab@gmail.com>
- In-Reply-To
- <cover-v2-00.27-00000000000-20220323T203149Z-avarab@gmail.com>
Use release_revisions() on the the "struct rev_info" in show_submodule_diff_summary() where we need to pre-initialize with "{ 0 }" to make sure that we won't segfault when calling release_revisions().
Most functions that use "struct rev_info" will call repo_init_revisions() early, which will do an equivalent memset(). In this case we might "goto out" before doing the equivalent of that operation, see the "goto" on "(!left || !right || !sub)" added in 8e6df65015f (submodule: refactor show_submodule_summary with helper function, 2016-08-31).
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- submodule.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/submodule.c b/submodule.c index 0510cb193b6..285c1896c9e 100644 --- a/submodule.c +++ b/submodule.c @@ -638,7 +638,7 @@ void show_submodule_diff_summary(struct diff_options *o, const char *path, struct object_id *one, struct object_id *two, unsigned dirty_submodule) { - struct rev_info rev; + struct rev_info rev = { 0 }; struct commit *left = NULL, *right = NULL; struct commit_list *merge_bases = NULL; struct repository *sub; @@ -664,6 +664,7 @@ void show_submodule_diff_summary(struct diff_options *o, const char *path, print_submodule_diff_summary(sub, &rev, o); out: + release_revisions(&rev); if (merge_bases) free_commit_list(merge_bases); clear_commit_marks(left, ~0);
-- 2.35.1.1452.ga7cfc89151f