shortlog: do not crash on parsing "[PATCH"
Annoyingly, it looked for the closing bracket in the author name instead of in the message, and then accessed the NULL pointer. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
Johannes Schindelin committed
Nov 19, 2006 at 17:28 UTC
72019cdefeb6b8fd7e8bff37b9c087302a45e29e
1 file changed
+9
-7
builtin-shortlog.c
+9
-7
@@ -108,13 +108,15 @@ static void insert_author_oneline(struct path_list *list,
108
free(buffer);
109
110
if (!strncmp(oneline, "[PATCH", 6)) {
111
- char *eob = strchr(buffer, ']');
112
-
113
- while (isspace(eob[1]) && eob[1] != '\n')
114
- eob++;
115
- if (eob - oneline < onelinelen) {
116
- onelinelen -= eob - oneline;
117
- oneline = eob;
111
+ char *eob = strchr(oneline, ']');
112
+
113
+ if (eob) {
114
+ while (isspace(eob[1]) && eob[1] != '\n')
115
+ eob++;
116
+ if (eob - oneline < onelinelen) {
117
+ onelinelen -= eob - oneline;
118
+ oneline = eob;
119
+ }
120
}
121
}
122