[PATCH 1/3] shortlog: do not crash on parsing "[PATCH"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
---
 builtin-shortlog.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index 48a2a0b..26212b0 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -108,13 +108,15 @@ static void insert_author_oneline(struct
 		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;
+			}
 		}
 	}
 
-- 
1.4.4.GIT

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]