1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-09 17:16:34 +02:00

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
This commit is contained in:
Junio C Hamano 2021-04-13 15:28:50 -07:00
commit f63add4aa8
2 changed files with 11 additions and 1 deletions

View File

@ -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"),

View File

@ -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