From 04f788023fd04e60a12c2a19787857c72b3817f4 Mon Sep 17 00:00:00 2001 From: Brodie Rao Date: Tue, 9 Aug 2011 20:49:12 -0700 Subject: commit: properly parse empty commit messages This ensures commit->message is always non-NULL, even if the commit message is empty or consists of only a newline. One such commit can be found in the wild in the jQuery repository: https://github.com/jquery/jquery/commit/25b424134f9927a5bf0bab5cba836a0aa6c3cfc1 --- src/commit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/commit.c') diff --git a/src/commit.c b/src/commit.c index 0ee3854c4..ced457ecc 100644 --- a/src/commit.c +++ b/src/commit.c @@ -221,10 +221,10 @@ int git_commit__parse_buffer(git_commit *commit, const void *data, size_t len) } /* parse commit message */ - while (buffer < buffer_end && *buffer == '\n') + while (buffer < buffer_end - 1 && *buffer == '\n') buffer++; - if (buffer < buffer_end) { + if (buffer <= buffer_end) { commit->message = git__strndup(buffer, buffer_end - buffer); if (!commit->message) return GIT_ENOMEM; -- cgit v1.2.1