Code

shortlog: do not crash on parsing "[PATCH"
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>
Sun, 19 Nov 2006 16:28:25 +0000 (17:28 +0100)
committerJunio C Hamano <junkio@cox.net>
Mon, 20 Nov 2006 06:59:05 +0000 (22:59 -0800)
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>
builtin-shortlog.c

index 48a2a0b0d3c86f75373038bc0f18a1e9c9754ae1..26212b009c6b1bb1a17dacc174d2e59d0dc54ef1 100644 (file)
@@ -108,13 +108,15 @@ static void insert_author_oneline(struct path_list *list,
                free(buffer);
 
        if (!strncmp(oneline, "[PATCH", 6)) {
-               char *eob = strchr(buffer, ']');
-
-               while (isspace(eob[1]) && eob[1] != '\n')
-                       eob++;
-               if (eob - oneline < onelinelen) {
-                       onelinelen -= eob - oneline;
-                       oneline = eob;
+               char *eob = strchr(oneline, ']');
+
+               if (eob) {
+                       while (isspace(eob[1]) && eob[1] != '\n')
+                               eob++;
+                       if (eob - oneline < onelinelen) {
+                               onelinelen -= eob - oneline;
+                               oneline = eob;
+                       }
                }
        }