Skip to content

Commit f63add4

Browse files
committed
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
2 parents 89b43f8 + c685450 commit f63add4

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

ref-filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ static int get_object(struct ref_array_item *ref, int deref, struct object **obj
16081608

16091609
if (oi->info.contentp) {
16101610
*obj = parse_object_buffer(the_repository, &oi->oid, oi->type, oi->size, oi->content, &eaten);
1611-
if (!obj) {
1611+
if (!*obj) {
16121612
if (!eaten)
16131613
free(oi->content);
16141614
return strbuf_addf_ret(err, -1, _("parse_object_buffer failed on %s for %s"),

t/t6300-for-each-ref.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,4 +1134,14 @@ test_expect_success 'for-each-ref --ignore-case works on multiple sort keys' '
11341134
test_cmp expect actual
11351135
'
11361136

1137+
test_expect_success 'for-each-ref reports broken tags' '
1138+
git tag -m "good tag" broken-tag-good HEAD &&
1139+
git cat-file tag broken-tag-good >good &&
1140+
sed s/commit/blob/ <good >bad &&
1141+
bad=$(git hash-object -w -t tag bad) &&
1142+
git update-ref refs/tags/broken-tag-bad $bad &&
1143+
test_must_fail git for-each-ref --format="%(*objectname)" \
1144+
refs/tags/broken-tag-*
1145+
'
1146+
11371147
test_done

0 commit comments

Comments
 (0)