Thomas Rast <trast@xxxxxxxxxxxxxxx> writes: > get_header()'s exit condition is finding the \n\n that separates the > commit header from its message. If such a double newline is not > present, it segfaults. Catch this case and die(). > > Signed-off-by: Thomas Rast <trast@xxxxxxxxxxxxxxx> > --- > > This would be the minimal fix to the pretty machinery so that 'git > rev-list --pretty=something HEAD' works when there are such broken > commits. > > If 2b goes in, there isn't really any point as we would never get this > far on such a commit. > > > pretty.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/pretty.c b/pretty.c > index 8688b8f..b7f097d 100644 > --- a/pretty.c > +++ b/pretty.c > @@ -440,7 +440,10 @@ static char *get_header(const struct commit *commit, const char *key) > const char *line = commit->buffer; > > for (;;) { > - const char *eol = strchr(line, '\n'), *next; > + const char *eol, *next; > + if (!line) > + die (_("malformed commit object: no separating \\n\\n?")); > + eol = strchr(line, '\n'); The same comment applies here. You can just return NULL in this case, I suppose? > if (line == eol) > return NULL; -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html