From e102d4353d7cfd69a597cd976eabdcb74641be69 Mon Sep 17 00:00:00 2001 From: Alex Riesen Date: Fri, 4 May 2007 23:51:32 +0200 Subject: [PATCH] Small correction in reading of commit headers Check if a line of the header has enough characters to possibly contain the requested prefix. Signed-off-by: Alex Riesen Signed-off-by: Junio C Hamano --- commit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/commit.c b/commit.c index eb911f44d7..7d78e786e9 100644 --- a/commit.c +++ b/commit.c @@ -640,7 +640,9 @@ static char *get_header(const struct commit *commit, const char *key) next = NULL; } else next = eol + 1; - if (!strncmp(line, key, key_len) && line[key_len] == ' ') { + if (eol - line > key_len && + !strncmp(line, key, key_len) && + line[key_len] == ' ') { int len = eol - line - key_len; char *ret = xmalloc(len); memcpy(ret, line + key_len + 1, len - 1); -- 2.11.4.GIT