summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0925ce4)
raw | patch | inline | side by side (parent: 0925ce4)
author | Marc-André Lureau <marcandre.lureau@gmail.com> | |
Thu, 17 Nov 2011 01:25:06 +0000 (02:25 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 17 Nov 2011 02:00:56 +0000 (18:00 -0800) |
This is to avoid reaching free of uninitialized members.
With an invalid .mailmap (and perhaps in other cases), it can reach
free(mi->name) with garbage for example.
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
With an invalid .mailmap (and perhaps in other cases), it can reach
free(mi->name) with garbage for example.
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
mailmap.c | patch | blob | history |
diff --git a/mailmap.c b/mailmap.c
index f12bb45a3f734e48f003a7a2943d168c26778603..4892d497343a2d04812e331b379af2f8403db139 100644 (file)
--- a/mailmap.c
+++ b/mailmap.c
} else {
/* create mailmap entry */
struct string_list_item *item = string_list_insert_at_index(index, old_email, map);
- item->util = xmalloc(sizeof(struct mailmap_entry));
- memset(item->util, 0, sizeof(struct mailmap_entry));
+ item->util = xcalloc(1, sizeof(struct mailmap_entry));
((struct mailmap_entry *)item->util)->namemap.strdup_strings = 1;
}
me = (struct mailmap_entry *)map->items[index].util;
if (new_email)
me->email = xstrdup(new_email);
} else {
- struct mailmap_info *mi = xmalloc(sizeof(struct mailmap_info));
+ struct mailmap_info *mi = xcalloc(1, sizeof(struct mailmap_info));
debug_mm("mailmap: adding (complex) entry for %s at index %d\n", old_email, index);
if (new_name)
mi->name = xstrdup(new_name);