diff options
author | Brodie Rao <brodie@bitheap.org> | 2011-08-09 20:49:12 -0700 |
---|---|---|
committer | Brodie Rao <brodie@bitheap.org> | 2011-10-12 15:14:25 -0700 |
commit | 04f788023fd04e60a12c2a19787857c72b3817f4 (patch) | |
tree | 3b4039c58f93e4d5d306c4c8cd2f99b9ccd9eee3 /src/commit.c | |
parent | 3eaf34f4c602b9e155e2f4c6ae26c9250ac37d50 (diff) | |
download | libgit2-04f788023fd04e60a12c2a19787857c72b3817f4.tar.gz |
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
Diffstat (limited to 'src/commit.c')
-rw-r--r-- | src/commit.c | 4 |
1 files changed, 2 insertions, 2 deletions
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; |