summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-05-25 12:05:35 -0700
committerJunio C Hamano <gitster@pobox.com>2012-05-25 12:05:35 -0700
commit407abbabe526ae37124794e0b09108dce129870e (patch)
tree5fda57be65a0f2ed553a89673b09a0c913c794fe
parent500cf7cbb49f9917194ccab4563376eeb025c152 (diff)
parenta9c7a8a8bef30bbbf87e0d4c0e64d50c676f70ed (diff)
downloadgit-407abbabe526ae37124794e0b09108dce129870e.tar.gz
Merge branch 'jk/pretty-commit-header-incomplete-line'
Fixes error codepath when a malformed commit object has a header line chomped in the middle.
-rw-r--r--pretty.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/pretty.c b/pretty.c
index 02a0a2bb43..dc57e5b329 100644
--- a/pretty.c
+++ b/pretty.c
@@ -439,12 +439,14 @@ static char *get_header(const struct commit *commit, const char *key)
int key_len = strlen(key);
const char *line = commit->buffer;
- for (;;) {
+ while (line) {
const char *eol = strchr(line, '\n'), *next;
if (line == eol)
return NULL;
if (!eol) {
+ warning("malformed commit (header is missing newline): %s",
+ sha1_to_hex(commit->object.sha1));
eol = line + strlen(line);
next = NULL;
} else
@@ -456,6 +458,7 @@ static char *get_header(const struct commit *commit, const char *key)
}
line = next;
}
+ return NULL;
}
static char *replace_encoding_header(char *buf, const char *encoding)