From: Jeff King Date: Sat, 9 Dec 2006 04:04:21 +0000 (-0500) Subject: shortlog: fix segfault on empty authorname X-Git-Tag: v1.5.0-rc0~146 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=90ffefe564cd849f88b1d1b5817eb25e3d57521b;p=git.git shortlog: fix segfault on empty authorname The old code looked backwards from the email address to parse the name, allowing an arbitrary number of spaces between the two. However, in the case of no name, we looked back too far to the 'author' (or 'Author:') header. Instead, remove at most one space between name and address. The bug was triggered by commit febf7ea4bed from linux-2.6. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/builtin-shortlog.c b/builtin-shortlog.c index f1124e261..7a2ddfe79 100644 --- a/builtin-shortlog.c +++ b/builtin-shortlog.c @@ -188,7 +188,7 @@ static void read_from_stdin(struct path_list *list) bob = buffer + strlen(buffer); else { offset = 8; - while (isspace(bob[-1])) + if (isspace(bob[-1])) bob--; } @@ -236,7 +236,7 @@ static void get_from_rev(struct rev_info *rev, struct path_list *list) author = scratch; authorlen = strlen(scratch); } else { - while (bracket[-1] == ' ') + if (bracket[-1] == ' ') bracket--; author = buffer + 7;