summaryrefslogtreecommitdiff
path: root/commit-reach.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-05-07 06:53:20 +0200
committerJunio C Hamano <gitster@pobox.com>2024-05-06 22:50:49 -0700
commitce992ce29a2ebed8daa1f46e712ba38b79b53062 (patch)
tree1e29ba651be0988783a0cabe1619d40db5a7718f /commit-reach.c
parent07658e9ce5b156876eebf81f39e0672a5347eae5 (diff)
builtin/blame: don't access potentially unitialized `the_hash_algo`
We access `the_hash_algo` in git-blame(1) before we have executed `parse_options_start()`, which may not be properly set up in case we have no repository. This is fine for most of the part because all the call paths that lead to it (git-blame(1), git-annotate(1) as well as git-pick-axe(1)) specify `RUN_SETUP` and thus require a repository. There is one exception though, namely when passing `-h` to print the help. Here we will access `the_hash_algo` even if there is no repo. This works fine right now because `the_hash_algo` gets sets up to point to the SHA1 algorithm via `initialize_repository()`. But we're about to stop doing this, and thus the code would lead to a `NULL` pointer exception. Prepare the code for this and only access `the_hash_algo` after we are sure that there is a proper repository. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-reach.c')
0 files changed, 0 insertions, 0 deletions