Skip to content

Commit c777560

Browse files
pks-tgitster
authored andcommitted
mailmap: always store allocated strings in mailmap blob
Same as with the preceding commit, the `git_mailmap_blob` may sometimes contain an allocated string and sometimes it may contain a string constant. This is risky and can easily lead to bugs in case the variable is getting re-assigned, where the code may then try to free the previous value to avoid memory leaks. Safeguard the code by always storing allocated strings in the variable. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 844d190 commit c777560

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mailmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ int read_mailmap(struct string_list *map)
216216
map->cmp = namemap_cmp;
217217

218218
if (!git_mailmap_blob && is_bare_repository())
219-
git_mailmap_blob = "HEAD:.mailmap";
219+
git_mailmap_blob = xstrdup("HEAD:.mailmap");
220220

221221
if (!startup_info->have_repository || !is_bare_repository())
222222
err |= read_mailmap_file(map, ".mailmap",

0 commit comments

Comments
 (0)