summaryrefslogtreecommitdiff
path: root/src/commit.c
diff options
context:
space:
mode:
authorColin Timmermans <colintimmermans@gmail.com>2010-11-05 18:04:46 +0200
committerVicent Marti <tanoku@gmail.com>2010-11-07 01:31:28 +0200
commit1081d909456b8149c8b7fd5eb16d39c6a55c4078 (patch)
tree39700352e27ff585e6b687e8ed005a43b94e2d6c /src/commit.c
parent4b7483a285024937df9623c3543390e717e2338a (diff)
downloadlibgit2-1081d909456b8149c8b7fd5eb16d39c6a55c4078.tar.gz
Fix parsing of commits that have no newlines in the message.
Diffstat (limited to 'src/commit.c')
-rw-r--r--src/commit.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/commit.c b/src/commit.c
index 4dbd7719a..08243f5c4 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -176,14 +176,15 @@ int commit_parse_buffer(git_commit *commit, void *data, size_t len, unsigned int
char *line_end;
size_t message_len = buffer_end - buffer;
- /* Short message */
+ /* Long message */
message_len = buffer_end - buffer;
commit->message = git__malloc(message_len + 1);
memcpy(commit->message, buffer, message_len);
commit->message[message_len] = 0;
- /* Long message */
- line_end = memchr(buffer, '\n', buffer_end - buffer);
+ /* Short message */
+ if((line_end = memchr(buffer, '\n', buffer_end - buffer)) == NULL)
+ line_end = buffer_end;
message_len = line_end - buffer;
commit->message_short = git__malloc(message_len + 1);