Skip to content

Commit 6876618

Browse files
peffgitster
authored andcommitted
record_author_date(): fix memory leak on malformed commit
If we hit the end-of-header without finding an "author" line, we just return from the function. We should jump to the fail_exit path to clean up the buffer that we may have allocated. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent fe6eb7f commit 6876618

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ static void record_author_date(struct author_date_slab *author_date,
594594
line_end = strchrnul(buf, '\n');
595595
if (!skip_prefix(buf, "author ", &ident_line)) {
596596
if (!line_end[0] || line_end[1] == '\n')
597-
return; /* end of header */
597+
goto fail_exit; /* end of header */
598598
continue;
599599
}
600600
if (split_ident_line(&ident,

0 commit comments

Comments
 (0)