sha1-name: do not assume that the ref store is initialized
authorJunio C Hamano <gitster@pobox.com>
Fri, 10 Apr 2020 00:03:45 +0000 (17:03 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Apr 2020 00:22:20 +0000 (17:22 -0700)
commit5ff4b920ebeadfa640f1b7d5929f58bb180a0519
treeda2742e849d99608a92d1c99a0985b701b878959
parentc931ba4e7806d4e76d367153cb8eaae022b83be7
sha1-name: do not assume that the ref store is initialized

c931ba4e (sha1-name.c: remove the_repo from handle_one_ref(),
2019-04-16) replaced the use of for_each_ref() helper, which works
with the main ref store of the default repository instance, with
refs_for_each_ref(), which can work on any ref store instance, by
assuming that the repository instance the function is given has its
ref store already initialized.

But it is possible that nobody has initialized it, in which case,
the code ends up dereferencing a NULL pointer.

Reported-by: Érico Rolim <erico.erc@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1-name.c
t/t4208-log-magic-pathspec.sh