record_author_date(): fix memory leak on malformed commit
authorJeff King <peff@peff.net>
Wed, 27 Aug 2014 07:56:31 +0000 (03:56 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 Aug 2014 17:30:42 +0000 (10:30 -0700)
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>
commit.c
index b6ffd623c89da5e800db37bcdb6437f2fb0fe98b..4ff8c66f9660c4871b26b315d71dba43efccfc64 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -594,7 +594,7 @@ static void record_author_date(struct author_date_slab *author_date,
                line_end = strchrnul(buf, '\n');
                if (!skip_prefix(buf, "author ", &ident_line)) {
                        if (!line_end[0] || line_end[1] == '\n')
-                               return; /* end of header */
+                               goto fail_exit; /* end of header */
                        continue;
                }
                if (split_ident_line(&ident,