summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-04-13 22:28:50 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-04-13 22:28:50 (GMT)
commitf63add4aa8e8c2ea413fe2bf3b5c9b0f55617e8b (patch)
tree438da5de939da18d89f81e84f9ea55e4f8957981
parent89b43f80a514aee58b662ad606e6352e03eaeee4 (diff)
parentc6854508808dd32e3fc20c5b021c4064d25f6438 (diff)
downloadgit-f63add4aa8e8c2ea413fe2bf3b5c9b0f55617e8b.zip
git-f63add4aa8e8c2ea413fe2bf3b5c9b0f55617e8b.tar.gz
git-f63add4aa8e8c2ea413fe2bf3b5c9b0f55617e8b.tar.bz2
Merge branch 'jk/ref-filter-segfault-fix'
A NULL-dereference bug has been corrected in an error codepath in "git for-each-ref", "git branch --list" etc. * jk/ref-filter-segfault-fix: ref-filter: fix NULL check for parse object failure
-rw-r--r--ref-filter.c2
-rwxr-xr-xt/t6300-for-each-ref.sh10
2 files changed, 11 insertions, 1 deletions
diff --git a/ref-filter.c b/ref-filter.c
index f0bd32f..a0adb45 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1608,7 +1608,7 @@ static int get_object(struct ref_array_item *ref, int deref, struct object **obj
if (oi->info.contentp) {
*obj = parse_object_buffer(the_repository, &oi->oid, oi->type, oi->size, oi->content, &eaten);
- if (!obj) {
+ if (!*obj) {
if (!eaten)
free(oi->content);
return strbuf_addf_ret(err, -1, _("parse_object_buffer failed on %s for %s"),
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index cac7f44..2e7c32d 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -1134,4 +1134,14 @@ test_expect_success 'for-each-ref --ignore-case works on multiple sort keys' '
test_cmp expect actual
'
+test_expect_success 'for-each-ref reports broken tags' '
+ git tag -m "good tag" broken-tag-good HEAD &&
+ git cat-file tag broken-tag-good >good &&
+ sed s/commit/blob/ <good >bad &&
+ bad=$(git hash-object -w -t tag bad) &&
+ git update-ref refs/tags/broken-tag-bad $bad &&
+ test_must_fail git for-each-ref --format="%(*objectname)" \
+ refs/tags/broken-tag-*
+'
+
test_done