Skip to content

Commit 49e6be5

Browse files
committed
Merge branch 'rs/pretty-safety'
* rs/pretty-safety: Make "--pretty=format" parser a bit more careful.
2 parents e25cfae + 7ed0988 commit 49e6be5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pretty.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ static void parse_commit_header(struct format_commit_context *context)
412412
if (i == eol) {
413413
state++;
414414
/* strip empty lines */
415-
while (msg[eol + 1] == '\n')
415+
while (msg[eol] == '\n' && msg[eol + 1] == '\n')
416416
eol++;
417417
} else if (!prefixcmp(msg + i, "author ")) {
418418
context->author.off = i + 7;
@@ -425,6 +425,8 @@ static void parse_commit_header(struct format_commit_context *context)
425425
context->encoding.len = eol - i - 9;
426426
}
427427
i = eol;
428+
if (!msg[i])
429+
break;
428430
}
429431
context->body_off = i;
430432
context->commit_header_parsed = 1;

0 commit comments

Comments
 (0)