mailmap: fix check-mailmap with full mailmap line
I recently had reported to me a crash from a coworker using the recently added sendemail mailmap support: 3724814 Segmentation fault (core dumped) git check-mailmap "bugs@company.xx" This appears to happen because of the NULL pointer name passed into map_user(). Fix this by passing "" instead of NULL so that we have a valid pointer. Signed-off-by: Jacob Keller <jacob.keller@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jacob Keller committed
Feb 21, 2025 at 15:47 UTC
bb60c5213134cda73c31940ec0fb33c361a064eb
2 files changed
+13
-1
builtin/check-mailmap.c
+1
-1
@@ -35,7 +35,7 @@ static void check_mailmap(struct string_list *mailmap, const char *contact)
35
mail = ident.mail_begin;
36
maillen = ident.mail_end - ident.mail_begin;
37
} else {
38
- name = NULL;
38
+ name = "";
39
namelen = 0;
40
mail = contact;
41
maillen = strlen(contact);
t/t4203-mailmap.sh
+12
@@ -114,6 +114,18 @@ test_expect_success 'check-mailmap --stdin simple address: no mapping' '
114
test_cmp expect actual
115
'
116
117
+test_expect_success 'check-mailmap name and address: mapping' '
118
+ test_when_finished "rm .mailmap" &&
119
+ cat >.mailmap <<-EOF &&
120
+ Bug Reports <bugs-new@company.xx> Bugs <bugs@company.xx>
121
+ EOF
122
+ cat >expect <<-EOF &&
123
+ <bugs@company.xx>
124
+ EOF
125
+ git check-mailmap "bugs@company.xx" >actual &&
126
+ test_cmp expect actual
127
+'
128
+
129
test_expect_success 'No mailmap' '
130
cat >expect <<-EOF &&
131
$GIT_AUTHOR_NAME (1):