summaryrefslogtreecommitdiffstats
path: root/mailmap.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-06-07 08:39:12 +0200
committerJunio C Hamano <gitster@pobox.com>2024-06-07 19:30:54 +0200
commitc77756015e66e5fc601cfb6a368c37ef1f94285a (patch)
tree818ccee902ae33e40d92290270b7f948278489b0 /mailmap.c
parentrevision: always store allocated strings in output encoding (diff)
downloadgit-c77756015e66e5fc601cfb6a368c37ef1f94285a.tar.xz
git-c77756015e66e5fc601cfb6a368c37ef1f94285a.zip
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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'mailmap.c')
-rw-r--r--mailmap.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/mailmap.c b/mailmap.c
index b2efe29b3d..3d1e092fef 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -216,7 +216,7 @@ int read_mailmap(struct string_list *map)
map->cmp = namemap_cmp;
if (!git_mailmap_blob && is_bare_repository())
- git_mailmap_blob = "HEAD:.mailmap";
+ git_mailmap_blob = xstrdup("HEAD:.mailmap");
if (!startup_info->have_repository || !is_bare_repository())
err |= read_mailmap_file(map, ".mailmap",