mirror of
https://github.com/git/git
synced 2024-08-25 02:35:46 +00:00
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 <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
cf593cc418
commit
e102d4353d
4
commit.c
4
commit.c
|
@ -640,7 +640,9 @@ static char *get_header(const struct commit *commit, const char *key)
|
||||||
next = NULL;
|
next = NULL;
|
||||||
} else
|
} else
|
||||||
next = eol + 1;
|
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;
|
int len = eol - line - key_len;
|
||||||
char *ret = xmalloc(len);
|
char *ret = xmalloc(len);
|
||||||
memcpy(ret, line + key_len + 1, len - 1);
|
memcpy(ret, line + key_len + 1, len - 1);
|
||||||
|
|
Loading…
Reference in a new issue