git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mailmap: xcalloc mailmap_info
@ 2011-11-16 23:51 Marc-André Lureau
  2011-11-17  1:10 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Marc-André Lureau @ 2011-11-16 23:51 UTC (permalink / raw)
  To: git; +Cc: Marc-André Lureau

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.
---
 mailmap.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mailmap.c b/mailmap.c
index 02fcfde..fbf7764 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -88,7 +88,7 @@ static void add_mapping(struct string_list *map,
 			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);
-- 
1.7.7

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-11-17  1:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-16 23:51 [PATCH] mailmap: xcalloc mailmap_info Marc-André Lureau
2011-11-17  1:10 ` Junio C Hamano
2011-11-17  1:25   ` Marc-André Lureau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).