Skip to content

Commit 8b3f33e

Browse files
Mischa POSLAWSKYgitster
authored andcommitted
ref-filter: initialize empty name or email fields
Formatting $(taggername) on headerless tags such as v0.99 in Git causes a SIGABRT with error "munmap_chunk(): invalid pointer", because of an oversight in commit f0062d3 (ref-filter: free item->value and item->value->s, 2018-10-19). Signed-off-by: Mischa POSLAWSKY <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0d0ac38 commit 8b3f33e

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

ref-filter.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -976,18 +976,18 @@ static const char *copy_name(const char *buf)
976976
if (!strncmp(cp, " <", 2))
977977
return xmemdupz(buf, cp - buf);
978978
}
979-
return "";
979+
return xstrdup("");
980980
}
981981

982982
static const char *copy_email(const char *buf)
983983
{
984984
const char *email = strchr(buf, '<');
985985
const char *eoemail;
986986
if (!email)
987-
return "";
987+
return xstrdup("");
988988
eoemail = strchr(email, '>');
989989
if (!eoemail)
990-
return "";
990+
return xstrdup("");
991991
return xmemdupz(email, eoemail + 1 - email);
992992
}
993993

t/t6300-for-each-ref.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,25 @@ test_expect_success 'Check ambiguous head and tag refs II (loose)' '
485485
test_cmp expected actual
486486
'
487487

488+
test_expect_success 'create tag without tagger' '
489+
git tag -a -m "Broken tag" taggerless &&
490+
git tag -f taggerless $(git cat-file tag taggerless |
491+
sed -e "/^tagger /d" |
492+
git hash-object --stdin -w -t tag)
493+
'
494+
495+
test_atom refs/tags/taggerless type 'commit'
496+
test_atom refs/tags/taggerless tag 'taggerless'
497+
test_atom refs/tags/taggerless tagger ''
498+
test_atom refs/tags/taggerless taggername ''
499+
test_atom refs/tags/taggerless taggeremail ''
500+
test_atom refs/tags/taggerless taggerdate ''
501+
test_atom refs/tags/taggerless committer ''
502+
test_atom refs/tags/taggerless committername ''
503+
test_atom refs/tags/taggerless committeremail ''
504+
test_atom refs/tags/taggerless committerdate ''
505+
test_atom refs/tags/taggerless subject 'Broken tag'
506+
488507
test_expect_success 'an unusual tag with an incomplete line' '
489508
490509
git tag -m "bogo" bogo &&

0 commit comments

Comments
 (0)