]> git.ipfire.org Git - thirdparty/git.git/commit
submodule--helper: libify even more "die" paths for module_update()
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Wed, 31 Aug 2022 23:18:14 +0000 (01:18 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 2 Sep 2022 16:16:25 +0000 (09:16 -0700)
commit86e16ed3a9fbf03bc8a5d4030177980193e30f57
tree904e5e6f1200ddb4cc2dbf1996f057029988e201
parentf5373deabd537daae3d7c34f6dfa4b62ed45be51
submodule--helper: libify even more "die" paths for module_update()

As noted in a preceding commit the get_default_remote_submodule() and
remote_submodule_branch() functions would invoke die(), and thus leave
update_submodule() only partially lib-ified. We've addressed the
former of those in a preceding commit, let's now address the latter.

In addition to lib-ifying the function this fixes a potential (but
obscure) segfault introduced by a logic error in
1012a5cbc3f (submodule--helper run-update-procedure: learn --remote,
2022-03-04):

We were assuming that remote_submodule_branch() would always return
non-NULL, but if the submodule_from_path() call in that function fails
we'll return NULL. See its introduction in
92bbe7ccf1f (submodule--helper: add remote-branch helper,
2016-08-03). I.e. we'd previously have segfaulted in the xstrfmt()
call in update_submodule() seen in the context.

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